If anyone is good with regex patterns, replacing strings and bash – you could do me a big favour:
I have a bunch of source files in a directory that have this line in various places. The line may well be preceded by spaces.
RELEASE_AND_NIL(_theNameOfAVariable);
I want to convert all occurences, overwriting the files with:
[_theNameOfAVariable release];
..any pointers please? I think someone showed me how to do this before with sed, but I forgot it was that long ago.
Thanks
EDIT
The actual command I used in the end was: (Thanks to @fardjad)
find . -name '*.m' -print0 | xargs -0 sed -i "" "s/RELEASE_AND_NIL(\(.*\))/[\1 release\]/g"
you can use
sed -ito perform in-place replacement and the regex replace pattern would be:so you can do:
and if you have bunch of source files, you can use
findandxargs: