函數(shù)輸出,return赃磨,echo
image.png
source /tmp/a.sh 裝載庫(kù)函數(shù)
image.png
sed -e 's/a/b/; s/c/d/' file //-e 多個(gè)
sed -f 從文件中執(zhí)行
image.png
awk 三段式:
awk 'BEGIN{print "aa"} {print "bbb"} END{print "cc"}' file
s

image.png
image.png
sed 遇到特殊字符
image.png
sed "2s/a/b" 第二行
sed "2,4s/a/b" 2 3 4行
sed "2,
 sed '1,2w test' file    sed -i '](https://math.jianshu.com/math?formula=s%2Fa%2Fb%22%20sed%20%22%2Faaa%2Fs%2Faaa%2Fbbb%2F%22%20xxx%20sed%20%223d%22%20xx%20sed%20'%2Faaa%2Fd'%20xxx%20sed%20'%2Fa%2F%2C%2Fb%2Fd'%20xxx%20sed%20'%2Fa%2F%2C%2Fd%2Fp'%20xxx%20sed%20'1i%20aaaa'%20xxx%20sed%20'1a%20aaaa'%20xxx%20sed%20'1c%20aaaa'%20xx%20!%5Bimage.png%5D(https%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F9967595-01dd89221b71d0d6.png%3FimageMogr2%2Fauto-orient%2Fstrip%257CimageView2%2F2%2Fw%2F1240)%20sed%20'1%2C2w%20test'%20file%20!%5Bimage.png%5D(https%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F9967595-c0b0ac67fcb41e55.png%3FimageMogr2%2Fauto-orient%2Fstrip%257CimageView2%2F2%2Fw%2F1240)%20!%5Bimage.png%5D(https%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F9967595-1e4159453ce3161a.png%3FimageMogr2%2Fauto-orient%2Fstrip%257CimageView2%2F2%2Fw%2F1240)%20!%5Bimage.png%5D(https%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F9967595-b1b93a665e6f59e2.png%3FimageMogr2%2Fauto-orient%2Fstrip%257CimageView2%2F2%2Fw%2F1240)%20sed%20-i%20')
awk '/aaa/{print $1}'
BRE
image.png
sed -n '/bash/{n;n;p}' a.sh
//找到bash這一行蚁飒,執(zhí)行next,執(zhí)行next,執(zhí)行p
sed N的用法
image.png
image.png
image.png
sed D多行刪除
image.png
保持空間
image.png
/aa/!p 排除命令
image.png
sed 'G' a.txt 在每一行后插入一個(gè)空白行
image.png
sed '=' a.txt 給行編號(hào)
sed '=' a.txt| sed 'N; s/\n/ /'
awk FS 分隔符 OFS 連接符
image.png
image.png
awk 腳本
image.png