linux常用命令(四)

 时间:2026-04-22 22:39:07

1、文本如下

[root@localhost shell]# cat testfile.txt                   

northwest       NW     Charles Main         3.0     .98     3       34

northwest       NW     Charles Main         3.0     .98     3       34

western         WE     Sharon Gray          5.3     .97     5       23

southwest       SW     Lewis Dalsass        2.7     .8      2       18

southern        SO     Suan Chin            5.1     .95     4       15

southeast       SE     Patricia Hemenway    4.0     .7      4       17

eastern         EA     TB Savage            4.4     .84     5       20

northeast       NE     AM Main Jr.          5.1     .94     3       13

northeast       NE     AM Main Jr.          5.1     .94     3       13

north           NO     Margot Weber         4.5     .89     5 针喝      9

north           NO     Margot Weber         4.5     .89     5       9

central         CT     Ann Stephens         5.7     .94     5       13

linux常用命令(四)

2、打印以north开头的行

-n: 取消默认的牢夏没输出

sed -n '/^north/p' testfile.txt 

linux常用命令(四)

3、列出第5-7行

sed -n '5,7p'蹲兼 testfile.txt 

linux常用命令(四)

4、删除第三行

cat testfile.txt | sed '3d'

linux常用命令(四)

5、删除2~5行

cat testfile.txt | sed  '2,5d'  

linux常用命令(四)

6、删除所有包含north的行

cat testfile.txt | sed  '/north/d'

linux常用命令(四)

7、在第二行后(即加在第三行)加上"nihao"

sed '2a nihao' testfile.txt 

linux常用命令(四)

  • linux常用命令(二)
  • linux常用命令?
  • Linux apache服务常用命令
  • linux之常用命令
  • Linux常用命令图
  • 热门搜索
    玷污是什么意思 metal是什么意思 繁花似锦是什么意思 陆续是什么意思 啧啧啧什么意思 什么是3d打印技术 ordinary是什么意思 1314什么意思 甘之如饴什么意思 运动会表扬稿