shell sed替换、删除文件中的某个字符串
时间:2019-11-29 13:27 来源:linux.it.net.cn 作者:IT
1、将当前目录下包含hello串的文件中,hello字符串替换为hi
sed -i "s/hello/hi/g" `grep "hello" -rl ./`
2、将某个文件中的hello字符串替换为hi
sed -i "s/hello/hi/g" test.txt
3、删除行首空格
sed -i 's/^ //g' test
4、删除行尾空格
sed -i 's/ $//g' test (责任编辑:IT)
1、将当前目录下包含hello串的文件中,hello字符串替换为hi sed -i "s/hello/hi/g" `grep "hello" -rl ./` 2、将某个文件中的hello字符串替换为hi sed -i "s/hello/hi/g" test.txt 3、删除行首空格 sed -i 's/^ //g' test 4、删除行尾空格 sed -i 's/ $//g' test (责任编辑:IT) |