luft
1
Hello all,
Search & replace works fine using sed on a single file.
Ex:
sed -i 's/day/night/g' test1.sh
There are many *.sh files in my current directory that I would like use sed on. I tried running the sed command using wild card but it did not work.
sed -i 's/day/night/g' *.sh
Any ideas?
Thanks.
Strange. What happens when you issue:
ls -l *.sh
do you get the expected result?
for fname in *.sh
do
sed -i 's/day/night/' $fname > tmp.tmp
mv tmp.tmp $fname
done
luft
4
Scrutinizer,
When I run ls -l *.sh I get correct results.
Jim,
I'm trying to use a single command if possible.
Thanks to both of you for your valuble time.
Strange. It work for me.
Can you describe me what are the results? Any output printed maybe? Have any file changed? Can you see if timestamps for the files are being uploaded?
jville
6
improvement to Jim M. script
for fname in *.sh
do
perl -pi -e 's/day/night/' $fname
done
luft
7
Thanks for your time and responses. Let me try out all your seggestions and keep you posted.
Hi,
Try the below line .It is working correctly. It replaced the day string into night for all *.sh files in the current directory.
sed -i "s/day/night/g" *.sh