Wednesday, July 10, 2013

command line - find and replace a text recursively in a specified folder in linux

$> grep -R <path of the folder> -ls -e "<text to be searched>" | xargs sed -i 's/<text to be searched>/<text to be replaced>/g'

one more way :

find <path of the folder> -exec grep -li '<text to be searched>'  {} \;

No comments:

Post a Comment