多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 服務器 > sed系列:行或者模式匹配刪除特定行

sed系列:行或者模式匹配刪除特定行

來源:程序員人生   發布時間:2015-01-21 08:15:59 閱讀次數:3543次
“p” command prints the buffer (remember to use -n option with “p”) 
“d” command is just opposite, its for deletion. ‘d’ will delete the pattern space buffer and immediately starts the next cycle. 

Syntax: 
# sed 'ADDRESS'd filename 
# sed /PATTERN/d filename 

Let us first creates thegeekstuff.txt file that will be used in all the examples mentioned below. 
# cat thegeekstuff.txt 
1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 
7. Productivity (Too many technologies to explore, not much time available) 
8. Website Design 
9. Software Development 
10.Windows- Sysadmin, reboot etc. 

例子1:刪除第n行 
sed ‘Nd’ filename 

As per sed methodology, 
It reads the first line and places in its pattern buffer. 
Check whether supplied command is true for this line, if true, deletes pattern space buffer and starts next cycle. i.e Read next line. 
If supplied command doesnt true, as its normal behaviour it prints the content of the pattern space buffer. 

$ sed 3d thegeekstuff.txt 
1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 
7. Productivity (Too many technologies to explore, not much time available) 
8. Website Design 
9. Software Development 

10.Windows- Sysadmin, reboot etc. 


例2:從第3行開始,每隔1行刪除 
$sed 3~2d thegeekstuff.txt 

1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
4. Security (Firewall, Network, Online Security etc) 
6. Cool gadgets and websites 
8. Website Design 
10.Windows- Sysadmin, reboot etc. 


例3:刪除從第4行到第8行 
$sed 4,8d thegeekstuff.txt 

1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
9. Software Development 
10.Windows- Sysadmin, reboot etc. 
$sed '4,8d' thegeekstuff.txt 
1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
9. Software Development 
10.Windows- Sysadmin, reboot etc. 
$sed '4,8'd thegeekstuff.txt 
1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
9. Software Development 

10.Windows- Sysadmin, reboot etc. 


例4:刪除最后1行 
$sed '$'d thegeekstuff.txt 

1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 
7. Productivity (Too many technologies to explore, not much time available) 
8. Website Design 
9. Software Development 
$sed '$d' thegeekstuff.txt 
1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 
7. Productivity (Too many technologies to explore, not much time available) 
8. Website Design 

9. Software Development 


例5:行匹配刪除 
$sed /Sysadmin/d thegeekstuff.txt 

2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 
7. Productivity (Too many technologies to explore, not much time available) 
8. Website Design 
9. Software Development 
$sed '/Sysadmin/d' thegeekstuff.txt 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 
7. Productivity (Too many technologies to explore, not much time available) 
8. Website Design 
9. Software Development 
$sed '/Sysadmin/'d thegeekstuff.txt 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 
7. Productivity (Too many technologies to explore, not much time available) 
8. Website Design 
9. Software Development 


例6:從匹配行到末尾行 
$sed '/Website Design/,$d' thegeekstuff.txt 

1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 
7. Productivity (Too many technologies to explore, not much time available) 
$sed '/Website Design/,$'d  thegeekstuff.txt 
1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 

7. Productivity (Too many technologies to explore, not much time available) 


例7:刪除匹配行和以后兩行 
$sed '/Storage/,+2d' thegeekstuff.txt 

1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
8. Website Design 
9. Software Development 
10.Windows- Sysadmin, reboot etc. 
$sed '/Storage/,+2'd thegeekstuff.txt 
1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
8. Website Design 
9. Software Development 

10.Windows- Sysadmin, reboot etc. 


例8:刪除空行 
$sed '/^$/d' thegeekstuff.txt 

1. Linux - Sysadmin, Scripting etc. 
2. Databases - Oracle, mySQL etc. 
3. Hardware 
4. Security (Firewall, Network, Online Security etc) 
5. Storage 
6. Cool gadgets and websites 
7. Productivity (Too many technologies to explore, not much time available) 
8. Website Design 
9. Software Development 
10.Windows- Sysadmin, reboot etc. 
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 日本xxxxx黄区免费看动漫 | 中文字幕久久久久一区 | 亚洲综合在线观看视频 | 69视频在线免费观看 | 亚洲欧美不卡视频 | 亚洲色播永久网址大全 | 亚洲国产成人久久综合一区 | 国产日韩欧美一区二区三区在线 | 国产伊人影院 | 一区二区免费视频 | 毛片影视 | 男女激情视频网站 | 一级做a爰片性色毛片新版的 | 免费一级a毛片 | 激情综合婷婷丁香六月花 | 97色婷婷成人综合在线观看 | www.免费黄色 | 亚洲午夜久久久精品影院视色 | 国产精品一国产精品免费 | 成人网在线看 | 亚洲一本之道在线观看不卡 | 欧美一级爱操视频 | 亚洲一区二区三区高清 不卡 | 男女激情动态视频 | 国产一成人精品福利网站 | 久草免费小视频 | 久久不卡一区二区三区 | japanese日本护士xx亚洲 | 91av福利| 亚洲 欧美 另类 综合 日韩 | 综合欧美亚洲 | 永久免费在线播放 | 久久精品久久精品 | 欧美日韩精品乱国产 | 亚洲精品二区 | 成年人免费在线视频观看 | 国产福利精品一区二区 | 99热久久久这里只有精品免费 | 亚洲一级二级三级 | 性欧美性另类双性人互交 | 国产亚洲欧美日韩在线一区 |