sed: 1: file: extra characters at the end of l command

On *BSD you must use

must use the like this

sed -i '' -e 's/FIND/REPLACE/' file
or
sed -i -e 's/FIND/REPLACE/' file

I try to modify nagios config file replace ip address to another,use find command to find all config files then use sed to modify the file content.

/usr/local/etc/nagios/objects]# find /usr/local/etc/nagios/objects/ -name '*.cfg' -exec sed -i '' -e 's/192\.168\.0/192\.168\.128/g' {} \;
or
/usr/local/etc/nagios/objects/ -name '*.cfg' -exec sed -i -e 's/192\.168\.0/192\.168\.128/g' {} \;

from:http://www.karlosp.net/blog/2010/11/24/sed-1-file-extra-characters-at-the-end-of-l-command/

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s