shell中sed命令

来源:互联网 发布:parallelsdesktop mac 编辑:程序博客网 时间:2024/05/01 16:57

sed -i '/cd ${LDIR_DEST}\/webextend\/pc && ln -s \/hard\/www_winclient\/bboxpc.exe ./a\ \tcd ${LDIR_DEST}\/webextend\/pc && ln -s \/hard\/www_winclient\/'$i' .'

#参考别人后自己改的,主要是加了个变量

sed -i '4i dfsdfdsad' xxx.txt #Insert contents between the fourth and fifth line在第4行插入,原来的第四行跑到第五

#参考下边,些的上边的

sed -i '4c dfsdfdsad' xxx.txt #Insert contents in the line 4 and overwrite the old在第4行插入覆盖原来的第4行 

#下边的是学的http://kaoshi.china.com/linux/learning/617077-1.htm

sed -i '/'"$test"'/d' xxx.txt #删除某行,用内容删除,这就必须 加'""'



sed -i '/\[nand_para\]/a\flag = 1' filename.txt #这是别人的

0 0