[NTLUG:Discuss] change words on every line in a file
o k
aaasssxxx at hotmail.com
Fri Mar 23 16:08:03 CDT 2012
All is there any have a good suggestion on change words on every line in a file. ex:original: dog 1234cat 1234mouse 1234houesr 1234 after changed dog 9899cat 9899mouse 9899house 9899 I have this, but seems to not woking: #!/bin/sh
v='9899'
cat file | while read s1 s2
do
if [ "$s2" != "$v" ]; then
echo $s1 '--' $s2
cat "$s1" ' ' "$IPADDR" >> file
sed -i '/$s2/ d' file
fi
done
exit 0 thank for your help.
More information about the Discuss
mailing list