赞
踩
sed -i 's/oldstring/newstring/g' full-path-file
-i extension
Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved.
It is not recommended to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situations where disk space is exhausted, etc.
centos中为:
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if extension supplied)
sed -i '' 's/oldstring/newstring/g' full-path-file
cd /tmp
echo "netingcn.com" > sed_test.txt
cat sed_test.txt
sed -i '' 's/netingcn/www\.netingcn/g' sed_test.txt
cat sed_test.txt
rm -rf sed_test.txt
cd -
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。