linux常用命令(四)

2024-11-19 11:01:56

1、文本如下[root@localhost shell]# cat testfile.txt northwest NW Charles Main 3.0 .98 3 34northwest NW Charles Main 3.0 .98 3 34western WE Sharon Gray 5.3 .97 5 23southwest SW Lewis Dalsass 2.7 .8 2 18southern SO Suan Chin 5.1 .95 4 15southeast SE Patricia Hemenway 4.0 .7 4 17eastern EA TB Savage 4.4 .84 5 20northeast NE AM Main Jr. 5.1 .94 3 13northeast NE AM Main Jr. 5.1 .94 3 13north NO Margot Weber 4.5 .89 5 9north NO Margot Weber 4.5 .89 5 9central CT Ann Stephens 5.7 .94 5 13

linux常用命令(四)

3、列出第5-7行sed -n '5,7p' testfile.txt

linux常用命令(四)

5、删除2~5行cat testfile.txt | sed '2,5d'

linux常用命令(四)

7、在第二行后(即加在第三行)加上"nihao"sed '2a nihao' testfile.txt

linux常用命令(四)
猜你喜欢