Differences between revisions 4 and 5
Revision 4 as of 2019-12-14 12:25:47
Size: 458
Editor: PieterSmit
Comment: add Xargs
Revision 5 as of 2020-04-04 07:11:57
Size: 832
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:

== Bash loop over files ==
 * Rather than using find and xargs, use globing to find and process files in bash
   * e.g. {{{
#By enabling the globstar option, you can glob all matching files in this directory and all subdirectories:
# Make sure globstar is enabled
shopt -s globstar
for i in **/*.txt; do # Whitespace-safe and recursive
    process "$i"
done
}}}

Describe Linux/FindGrepAwkSedXargs here.

Find files containing something in Linux

Search dir for files containing string and replace all of them

##e.g. search for tentant -> tenant
grep -irlZ 'tentant' ./ |  xargs -0  sed -i 's/tentant/tenant/g'

Bash loop over files

  • Rather than using find and xargs, use globing to find and process files in bash
    • e.g.

      #By enabling the globstar option, you can glob all matching files in this directory and all subdirectories:
      # Make sure globstar is enabled
      shopt -s globstar
      for i in **/*.txt; do # Whitespace-safe and recursive
          process "$i"
      done


CategoryLinux

vigor: Linux/FindGrepAwkSedXargs (last edited 2020-06-26 13:19:18 by PieterSmit)