Thomas Mccaffery
Thomas Mccaffery

Reputation: 385

Search and Replace under linux?

I tried the following but not adding '' this example

I want to replace FILENAME_LOGIN to 'login.php'

Tried this:

grep -r "login.php" -l | tr '\n' ' ' | xargs sed -i 's/"login.php"/'login.php'/g'

However, it gives me login.php not 'login.php'

Thanks

Upvotes: 0

Views: 63

Answers (3)

Ed Morton
Ed Morton

Reputation: 203129

find ./ -type f -exec sed -i -e 's/FILENAME_LOGIN/'\''login.php'\''/g' {} \;

Upvotes: 0

Thomas Mccaffery
Thomas Mccaffery

Reputation: 385

I figured it out:

find ./ -type f -exec sed -i -e 's/FILENAME_LOGIN/'login.php'/g' {} \;

Upvotes: 0

campovski
campovski

Reputation: 3153

You only need sed for this:

sed -i -e "s/FILENAME_LOGIN/'login.php'/g" /your/file

Upvotes: 1

Related Questions