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
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