Walk a directory/Recursively: Difference between revisions
→{{header|UnixPipes}}: xargs
(→{{header|UNIX Shell}}: globstar and dotglob) |
(→{{header|UnixPipes}}: xargs) |
||
Line 1,617:
=={{header|UnixPipes}}==
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>▼
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}}==
|