0

I have been looking around and I find grep and Gawk fairly difficult to grasp without much knowledge on UNIX. I have about 50 php files and I need to replace "stringA" inside each of these files by "stringB" Does someone know of an easy to use tool? If I had extra time I could write one up in PHP with the search functions.

1
  • Sed is fairly advanced, I believe there are text editors out there that will let you open a bunch of files at once and do a find/replace with the GUI. Commented Nov 16, 2011 at 17:50

4 Answers 4

1

Assuming they are all in the same folder:

sed -i 's/stringA/stringB/g' *.php
Sign up to request clarification or add additional context in comments.

Comments

0

I think you can open multiple files with ultra edit and do a find replace all on them. http://www.ultraedit.com/

1 Comment

While "workable", I think shell proficiency is very important for anyone developing on UNIX. Shell pipelines are more reliable, more flexible, lighter and can work even when you don't have X running.
0
sed -i 's/stringA/stringB/g' *

Be careful though

Comments

0

Use Perl

noufal@sanitarium% cat tmp
StringA
Test nameStringB
Testing StringA
StringC

noufal@sanitarium% perl -e s/StringA/StringB/g -pi tmp 
noufal@sanitarium% more tmp
StringB
Test nameStringB
Testing StringB
StringC

You can pass multiple files to the command.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.