Let say you want to search all "*.conf" files under “/home/jboss” having string “cache” in it and display the output.
# find /home/jboss -name *.conf -type f | xargs grep “cache”
(or)
# find /home/jboss -name *.conf -type f -exec grep -HI "cache" {} \;
(or)
# find /home/jboss -name *.conf -type f -exec grep -HI "cache" {} \;
Now you have a slightly different requirement:
You want to search all "*.conf" files under “/home/jboss” having string “cache” and replace it with "core".
# perl -p -i -e 's/cache/core/g' `find /home/jboss -type f -name *.conf`
Another version:
# find /home/jboss -type f -name *.conf | xargs grep -l cache | xargs perl -p -i -e 's/cache/core/g'
No comments:
Post a Comment