-exec
The find action that runs a command on the entries it finds, with {} standing for each file name.
In more detail
Ending it with + passes many names to one command, like xargs, and ending it with \; runs the command once per file. Either way file names arrive as separate arguments, so spaces and newlines in names are safe.
Example
find data -name "*.log" -exec grep -c start {} +Related terms
- find command — The find command, which walks a directory tree and prints, or acts on, every entry that passes its tests.
- xargs — The command that reads items from its standard input and runs another command with them as arguments, in batches.
Taught in
- find And xargs — Bash Scripting & Command Line Automation
- The Upload That Ran: Mount Options, Swap And Network Shares — CompTIA Linux+ (XK0-006) Exam Prep
- The Reindex That Died With The VPN: Jobs, cron, at And Timers — CompTIA Linux+ (XK0-006) Exam Prep
- Works On My Laptop: Images, Containers, Volumes And Networks — CompTIA Linux+ (XK0-006) Exam Prep
- The Pager Command That Opened A Root Shell: sudo, su And Least Privilege — CompTIA Linux+ (XK0-006) Exam Prep