sed and other related review

 sed phase prints the content between two lines:

 

sed -n '/ 111 /, / aad / p' fuxi.txt

grep -n ".*" fuxi.txt

sed -n '2,9'p fuxi.txt

 

sed how to convert upper and lower case

sed 's/\b[az]/\u&/g' fuxi.txt the first letter becomes uppercase

sed 's/[az]/\u&/g' fuxi.txt converts all to uppercase u& = up +& abbreviation

sed 's/[AZ]/\l/g' fuxi.txt converts all to lowercase l& = low +& abbreviation

 

sed add a number to the end of a line in a file

Which line was found by sed 's/\(^n.*\)/\1, the added content/' fuxi.txt

 

sed delete the next line to the last line of a keyword

 

sed '/^a.*/{p;:a;N;$!ba;d}' fuxi.txt

 

if matches "^a,*"
: a
appends the next line
if does not match "$"
goto a
finally exits the loop, and the d command deletes.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325170678&siteId=291194637
sed