| Start |
|---|
| Searching for a file by name or extension To find files/directories with a specific name, relative to To find files/directories with a specific extension, use a wildcard: To find files/directories matching one of many extensions, use the To find files/directories which name begin with abc and end with one alpha character following a one digit: To find all files/directories located in a specific directory To search for files only (not directories), use To search for directories only (not regular files), use |
| Executing commands against a found file Sometimes we will need to run commands against a lot of files. This can be done using The above command will recursively find all directories ( If your files names or directories have a space character in them, this command may choke; a solution is to use the following In the above example, the The preferred way to do this is to skip the Here, the You can alternatively pass all file names to a single call of This is also the behaviour of the above A third option is to let bash loop over the list of filenames This is syntactically the most clunky, but convenient when you want to run multiple commands on each found file. However, this is unsafe in the face of file names with odd names. which will replace all spaces in file names with underscores.(This example also won't work if there are spaces in leading directory names.) The problem with the above is that This way, the The mysterious |
| Finding file by access / modification time On an To find files that have been modified within the last 2 hours: To find files that have not been modified within the last 2 hours: The above example are searching only on the modified time - to search on access times, or changed times, use General format:
Find files that have been modified within the last 2 days: Find files that have not been modified within the last 2 days Use General format:
Find files modified in a range of dates, from 2007-06-07 to 2007-06-08: Find files accessed in a range of timestamps (using files as timestamp), from 1 hour ago to 10 minutes ago: General format:
|
| Finding files according to size Find files larger than 15MB: Find files less than 12KB: Find files exactly of 12KB size: Or Or Or General format: Find files of n-block size, where +n means more than n-block, -n means less than n-block and n (without any sign) means exactly n-block Block size:
|
| Filter the path The To find only files containing To find only files within a folder called To find only files within a folder called To find all files except the ones contained in a folder called To find all file all files except the ones contained in a folder called |
| Finding files by type To find files, use the To find directories, use the To find block devices, use the To find symlinks, use the |
| Finding files by specific extension To find all the files of a certain extension within the current path you can use the following To find all files of type Syntax
|
Read Article
https://develop.horje.com/learn/1434/reference