...
Here is a really straightforward example of using xargs,
- -t will show you what xargs is about to execute before it executes it.
- -n1 limits the arguments passed by the directory to pass one argument, in this case one file name at a time.
...
Code Block | ||
---|---|---|
| ||
find [folder] -type f | xargs -I {} grep -li "text" {} | xargs perl -pi -e 's/[text_to_search_for]/[text_to_search_for]/g' find [folder] -type f { # search the specified folder for all files, returns full path of each file} | xargs -I {} grep -li "[text]" {} {# piped into xargs with to grep for all files containing specified text ignoring case} | xargs perl -pi -e 's/[text_to_search_for]/[text_to_replace_with]/g' {# pipe list of files and search/replace with specified text} |
...