To find all ‘.c’ source code files in the current directory (and sub directories):
To find find all the ‘.c’ and ‘.h’ source code files you can combine multiple search terms:
Finding all the files that match multiple different file extensions is also possible using a regular expression though I find this method rather harder to remember!
Count directories and files in a folder
To count how many files folders and symbolic links are in a particular directory (including sub folders).
This command searches the current folder for each of the types of file specified in the ‘for’ loop, and counts the number of lines of output for each to produce a summary giving the total number of files, folders and links.
If you just want to know what is in the current folder and don’t want to count any files, folders or links in any sub-folders you can use limit the search to just the current folder and exclude hidden files.
The following command find all the matching files in the current folder (excluding hidden files) and then generates a checksum for each one, saving the output in a file.
Find large files
The following commands both use use ‘-size’ to find any file larger than a certain size, but the first one also shows how ‘find’ can be used to run more then one command for each matching file.
The second command is less ‘interesting’ but does the same thing more efficiently as ‘stat’ can be used to print the filename as well as the file size.