Differences between revisions 3 and 5 (spanning 2 versions)
Revision 3 as of 2019-12-14 12:25:10
Size: 411
Editor: PieterSmit
Comment:
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 1: Line 1:
## page was renamed from Linux/FindGrepAwkSed
Line 12: 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

Linux/FindGrepAwkSedXargs (last edited 2024-01-24 20:48:46 by PieterSmit)