sed刪除文件中的一行內(nèi)容的腳本代碼
更新時間:2013年03月02日 19:23:05 作者:
sed刪除文件中的一行內(nèi)容的腳本代碼,需要的朋友可以參考下
先來看下原始文件的內(nèi)容:
root@localhost ~]# cat file.txt
hello world
a:b:c -h -n
a:b:c -h -n
sed根據(jù)條件刪除相關(guān)的行:
[root@localhost ~]# sed -i '/a:b:c -h -n/d' file.txt
[root@localhost ~]# cat file.txt
hello world
sed根據(jù)條件進行相關(guān)內(nèi)容的替換:
[root@localhost ~]# sed -i 's/hello/baidu/' file.sh
[root@localhost ~]# cat file.sh
baidu world
復(fù)制代碼 代碼如下:
root@localhost ~]# cat file.txt
hello world
a:b:c -h -n
a:b:c -h -n
sed根據(jù)條件刪除相關(guān)的行:
復(fù)制代碼 代碼如下:
[root@localhost ~]# sed -i '/a:b:c -h -n/d' file.txt
[root@localhost ~]# cat file.txt
hello world
sed根據(jù)條件進行相關(guān)內(nèi)容的替換:
復(fù)制代碼 代碼如下:
[root@localhost ~]# sed -i 's/hello/baidu/' file.sh
[root@localhost ~]# cat file.sh
baidu world
相關(guān)文章
Linux應(yīng)用調(diào)試之strace命令詳解
strace常用來跟蹤進程執(zhí)行時的系統(tǒng)調(diào)用和所接收的信號。下面通過本文給大家分享Linux應(yīng)用調(diào)試之strace命令,需要的朋友參考下吧2017-12-12
獲取同一網(wǎng)段下所有機器MAC地址的shell腳本
有時候需要在當前同一網(wǎng)段下所有機器MAC地址,需要的朋友可以參考下2013-01-01
script_tool_for_linux.bash: Linux 環(huán)境下的 hosts 一鍵部署腳本
這篇文章主要介紹了script_tool_for_linux.bash: Linux 環(huán)境下的 hosts 一鍵部署腳本,需要的朋友可以參考下2016-04-04

