Linux Command - find with -exec action
Explore -exec
action for find
command.
-exec
-exec command syntax
1 | -exec command ; |
-exec
- Execute command; true if 0 status is returned. All following arguments to find are taken to be arguments to the command until an argument consisting of ; is encountered. The string {} is replaced by the current file name being processed everywhere it occurs in the arguments to the command.
Example
find .png files and execute ‘ls -lh’ command
1 | find . -name "*.png" -exec ls -lh {} \; |
fine .log files and remove with prompt
1 | find -name "*.log" -mtime -1 -exec rm -i {} \; |