sed_notes
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sed_notes [2021/01/28 21:40] – [backup with timestamp] raju | sed_notes [2021/01/28 21:50] (current) – raju | ||
---|---|---|---|
Line 1: | Line 1: | ||
==== replace text between two lines with a file ==== | ==== replace text between two lines with a file ==== | ||
+ | tags | line numbers, sed command to insert a file | ||
Replace lines between \$start and \$end in main.txt with contents of part.txt | Replace lines between \$start and \$end in main.txt with contents of part.txt | ||
Line 52: | Line 53: | ||
j k l | j k l | ||
</ | </ | ||
+ | |||
+ | ==== insert file at the beginning of another file ==== | ||
+ | This will insert part.txt at the beginning of main.txt. | ||
+ | |||
+ | < | ||
+ | sed -e "1 e cat part.txt" | ||
+ | </ | ||
+ | |||
+ | Example: | ||
+ | < | ||
+ | $ cat main.txt | ||
+ | a b c | ||
+ | d e f | ||
+ | g h i | ||
+ | j k l | ||
+ | |||
+ | $ cat part.txt | ||
+ | x y z | ||
+ | p q r | ||
+ | s t u | ||
+ | |||
+ | $ sed -e "1 e cat part.txt" | ||
+ | x y z | ||
+ | p q r | ||
+ | s t u | ||
+ | a b c | ||
+ | d e f | ||
+ | g h i | ||
+ | j k l | ||
+ | </ | ||
+ | |||
+ | Found it in: https:// | ||
==== backup with timestamp ==== | ==== backup with timestamp ==== |
sed_notes.1611870032.txt.gz · Last modified: 2021/01/28 21:40 by raju