To replace a string in all files recursively with your matching string globally, The following perl utility is very helpful -
Go to the directory and run -
# perl -p -i -e 's/string/replace-with/g' `grep -rl string *`
If your string contains '/' for example you have to replace '/home/sandy' with '/home/mandy' the use it like -
# perl -p -i -e 's/\/home\/sandy/\/home\/mandy/g' `grep -rl sandy *`
If you have any query, please post your comments.
Thanks !
Go to the directory and run -
# perl -p -i -e 's/string/replace-with/g' `grep -rl string *`
If your string contains '/' for example you have to replace '/home/sandy' with '/home/mandy' the use it like -
# perl -p -i -e 's/\/home\/sandy/\/home\/mandy/g' `grep -rl sandy *`
If you have any query, please post your comments.
Thanks !
No comments:
Post a Comment