Reputation: 33292
How would I replace one pattern with another for every file with extension .cc and .h recursively? Not sure if I need to prevent it from going into .svn directories.
first attempt
#!/bin/bash
for file in `find . -name '*.cc' -or -name '*.h'`; do \
sed -e s/$1/$2/g -i temp $file
done
Upvotes: 1
Views: 297
Reputation: 5601
If your project is managed under linux platform, You can do sth like that inside the bash:
for file in `find . -name '*.cpp' -or -name '*.h'`; do \
cat $file | sed s/$1/$2/g > tmp
mv tmp $file
done
Each svn file has '*-base' extension so all of them will be unchanged. This script will only affect to *h and *cc files.
Upvotes: 2
Reputation: 3706
You can search and replace using regular expressions through certain files in Eclipse project explorer, for example. I'm sure there are lots of tools that can do this, but Elipse comes to mind first.
To do this you need to invoke the "Search" dialog, place your pattern in the search field, specify extensions with a wildcard and press "Replace",
Upvotes: 0