noorsam
1
I have 100+ python files in a single directory. I need to replace a specific path occurrence with a variable name.
Following are the find and the replace strings:
Findstring--"projects\\Debugger\\debugger_dp8051_01\\debugger_dp8051_01.cywrk"
Replacestring--self.projpath
I tried following without success
for y in *;
do sed "s/\"projects\\Debugger\\debugger_dp8051_01\\debugger_dp8051_01.cywrk\"/self.projpath/g" $y > temp;
mv temp $y;
done
Can someone please help me with the correct solution?
Post your sample input file.
for y in *;
do perl -pe 's/\Q"projects\\Debugger\\debugger_dp8051_01\\debugger_dp8051_01.cywrk"\E/self.projpath/' $y > temp;
mv temp $y;
done
kurumi
4
$ ruby -i.bak -ne 'BEGIN{o=%q(projects\\\\Debugger\\\\debugger_dp8051_01\\\\debugger_dp8051_01.cywrk)};print if gsub(o,"self.projpath")' *.py
rdcwayx
5
awk '{gsub(/"projects\\\\Debugger\\\\debugger_dp8051_01\\\\debugger_dp8051_01.cywrk"/,"self.projpath")}1' *.py
sed 's/"projects\\\\Debugger\\\\debugger_dp8051_01\\\\debugger_dp8051_01.cywrk"/self.projpath/' *.py
noorsam
6
It worked correctly for me now...
Thanks for your quick responses.