Jump to content

Walk a directory/Recursively: Difference between revisions

(→‎{{header|UNIX Shell}}: globstar and dotglob)
Line 1,617:
 
=={{header|UnixPipes}}==
 
Find accepts file globbing params too as -name, here I use regexp from grep.
As illustrated [[#UNIX Shell|above]], the "find" command can be used with the -name option to match simple patterns. To find files matching more complex patterns, the results of "find" can be piped, e.g.
<lang bash>find . | grep '.*\.txt$'</lang>
 
<lang bash>find . -type f | grepegrep '.*\.txt$|\.TXT$'</lang>
 
One way to run a command against each file that is found is to use "xargs", but if there is any possibility that a filename contains a space or tab character, then the following model should be used:
 
<lang bash> find . -type f -name "*.txt" -print0 | xargs -0 fgrep sometext</lang>
 
=={{header|Zsh}}==
2,502

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.