Re: sed question
From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 02/19/04
- Next message: rakesh sharma: "Re: using find in a script: how to know it returns no files?"
- Previous message: Peter Lee: "Re: sed question"
- In reply to: Nasir: "sed question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 19 Feb 2004 09:37:13 -0800
nasirmahmood@sat.net.pk (Nasir) wrote in message
> I have question on sed
> I have mutiple file containing IP address "66.132.176.100" and now I
> want to change all those matching files to replace this IP with
> another of let's say 66.132.176.99
> What I did was
>
> for i in `find -type f -exec 'grep' '-H' '66.132.176.100' '{}' \;`
> do
> sed 's/66\.132\.176\.100/66\.132\.176\.99/' < $i > $i
> done
>
You can accomplish all of the above within the 'find' command itself:
/bin/find . -type f -exec sh -c '
grep -l "66\\.132\\.176\\.100" "$1" > /dev/null 2>&1 && \
sed -e "s:\\(\\<66\\.132\\.176\\.\\)100\\>:\\199:" "$1" > "/tmp/$1" && \
mv -f "/tmp/$1" .
' {} {} \;
- Next message: rakesh sharma: "Re: using find in a script: how to know it returns no files?"
- Previous message: Peter Lee: "Re: sed question"
- In reply to: Nasir: "sed question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|