40. Find Utilities - Commands & Files Searching Usages
Contents
There are many things we can do with some combination of find and other commands. We can use some commands on the files we find.
Let’s prepare some files and directories for demonstration:
|
|
Run Command on One File or More Files
We can apply a command on top of a single file or multiple files that match.
Print the Content of Each Matching File
We can apply a command to each matching file individually with the execdir option combined with the {} symbol:
Print the Contents of All Matching Files
We can move the {} symbol to the end and ends with a + symbol to apply the command to all matching files at the same time:
Remove Matching Files
By adding the -delete option, we can delete the matching files:
|
|
Change Permissions of the Matching Files
We can specify the type of file to which the chmod command applies through the -type option of the find command.
Change Permissions of the Matching Regular Files
Let’s enable user group’s write permission on the matching files:
|
|
Change Permissions of the Matching Directories
Let’s enable user group’s write permission on the matching directories:
|
|
References 3 Actions, 9 Common Tasks
Author Dong Chen
LastMod Tue Mar 12 2019