I used the following script
cd pathname
for y in `ls *`;
do sed "s/ABCD/DCBA/g" $y > temp; mv temp $y;
done
and it worked fine for finding and replacing strings with names etc. in all files of the given path.
I'm trying to replace a string which consists of path (location of file)
say instead of ABCD i have to replace c:/mydocuments/pictures to
d:/mypics/personal , as metacharacters wont be searched in unix this script is failing to replace the string which has a path in it.
now my script is
cd pathname
for y in `ls *`;
do sed "s/'c:/mydocuments/pictures'/'d:/mypics/personal'/g" $y > temp; mv temp $y;
done
i tired giving the path in single quotes and double quotes, but i see error
sed: command garbled: s/'c:/mydocuments/pictures'/'d:/mypics/personal'/g
And all the contents of the files in the path are erased.
Also tried the following using
sed -
sed -e "s!AAA!BBB!g"
sed =e "s+AAA+BBB+g"
as the string has / in the file location path
Is there any other way to work this out.
Thanks