Professional Documents
Culture Documents
SED Examples
SED Examples
txt
spinach,pepperoni,feta
pepperoni,Feta,mushrooms
bacon,banana peppers,feta
cheese,feta
/disk2/home/avasundh> sed '4,$d' file2.txt - It will delete from 4th line till
end , print first 3 lines
day is today
now lets have a party today
yu r good
/disk2/home/avasundh> sed -n '4,$p' file2.txt - It will print form the 4th line
till end.
have a nice day
today is tomorrow
day
the day is nice
this is a day
/disk2/home/avasundh> sed '=' file2.txt -> -> = used to print the line numbers
1
day is today
2
now lets have a party today
3
yu r good
4
have a nice day
5
today is tomorrow
6
day
7
the day is nice
8
this is a day
/disk2/home/avasundh> sed 'G' file1.txt -> G -Add the 1 line space bw the
lines
spinach,pepperoni,feta
pepperoni,Feta,mushrooms
bacon,banana peppers,feta
cheese,feta
/disk2/home/avasundh> sed 'G;G' file1.txt -> G;G used to add 2 lines of spaces
spinach,pepperoni,feta
pepperoni,Feta,mushrooms
bacon,banana peppers,feta
cheese,feta