SED COMMANDS
Insert a blank line after each line /Insert two blank lines
- sed G filename.txt
- sed 'G;G' filename.txt
- sed '/^$/d' filename.txt
Insert 5 spaces to the left of every lines
- sed 's/^/ /' filename.txt
- sed '10d' filename.txt
- sed '5,10d' filename.txt
- sed '10,$d' filename.txt
- sed '/Nagaraju/d' filename.txt
- sed '/Nagaraju/,+5d' filename.txt
- sed -n '10,50p' filename.txt
- sed -n '5,10d' filename.txt
- sed -n '10p' filename.txt
- sed -m '5,$p' filename.txt
- sed -n /Nagaraju/p filename.txt
- sed -n '1,/Nagaraju/p' filename.txt
- sed 's/Raju/Nagaraju/g' filename.txt
To replacing the nth occurrence of the pattern
- sed 's/Raju/Nagaraju/2' filename.txt
To replacing pattern on a specific line number
- sed '10 s/Raju/Nagaraju/' filename.txt
To replacing the pattern on a defined range and ignoring the case
- sed '10,20 s/Raju/Nagaraju/i' filename.txt
Replace one pattern followed by the another pattern
- sed '/is/ s/Raju/Nagaraju/' filename.txt
Replace a pattern with other except in the nth line
- sed -i '5!s/Raju/Nagaraju/' filename.txt
- sed -n '1~2p' filename.txt
- sed -n '/pattern1/,//pattern2/p' filename.txt
Tar the file
tar -cvf filename.tar filename
Untar the file
tar -xvf filename.tar
No comments:
Post a Comment