sed¶
Perform basic text transformations on an input stream, in some ways similar to an editor.
-iedit files in-place instead of printing to standard output-nsuppress output
replace¶
replace{"title":" with nothing: sed 's/{"title":"//g'case convert¶
sed 's/.*/\L&/' #to lower
sed 's/.*/\U&/' #to upper
sed 'y/'$(printf "%s" {A..Z} "/" {a..z} )'/'
sed 'y/'$(printf "%s" {a..z} "/" {A..Z} )'/'
print selected lines¶
only print 1st line in file1 and last line in last file
delete selected lines¶
deletes lines 2 to 5 in the input
delete matching lines and replace¶
delete lines matching regex /^foo/, and replace hello with world
seq 2 | sed -e 1ahello -e 2ifoo | sed '/^foo/d;s/hello/world/'
seq 2 | sed -e 1ahello | sed -e '2ahahahah' -e s/hello/world/
select lines with step number¶
select lines based on address¶
sed '2s/hello/world/' #only replace on line 2
sed '2,5s/hello/world/' #only replace lines 2-5
sed '2,5!s/hello/world/' #only replace lines not 2-5
sed '/foo/s/hello/world/' #only replace lines contain foo
sed '/foo/!s/hello/world/' #only replace lines not contain foo