Useful Command Line Command - Find

Use the following command to search for a file in a directory using the entire file name or part of the file name:
find . -name "*<FILE-NAME>*"

If there are files that match the search criteria, the search results will display the exact path of the files.

* The asterisk wild character at the beginning and end of the file name means any word at the start and the end of the file name.
-o -or  Either one of the latter commands can be used to refer to OR.  
-a -and Either one of the latter commands can be used to refer to AND.

Example 1:

If you wish to search for files that have the word style in it, you can use the following command in the terminal.
find . -name "*style*"

Example 2:

find . -name "*wso2.jaggery*" -a -name "*style*"
./repository/components/features/org.wso2.jaggery.styles_0.9.0.SNAPSHOT_07042013

When the above command was entered, in response the exact path (/repository/components/plugins/ directory) where the org.wso2.jaggery.styles_0.9.0.SNAPSHOT_07042013 file was located was provided.
Photo by Markus Spiske on Unsplash

Comments