Want to search files using a file extensions like: *.css, *.js, *.php, *.txt, or *.zip etc. in Linux.
Use the following command.
sudo find /home/user/Documents -type f -name "*.css"
Let’s understand the above command.
- sudo enables administrative access.
- find is a find, query, or search instruction.
- /home/user/Documents is working directory or a directory where you want to find things.
- -type f instructs to look for files only.
- -name “input search term” will search for file name based on your input search term. It is a base of the file name (the path with the leading directories removed) that matches the shell pattern.
- -iname “input search term” is the same as a -name except file names are not case sensitive. For example, ‘style.css’ will match STYLE.css, Style.css, Style.Css, and so on.
- Usually, administrative access is not required for the basic searches.
- You can use an asterisk symbol in the input search term for dynamic search.
Have any doubts? Feel free to leave a comment in the comment section below.