How to find a folder in Linux using the command line

To find a folder in Linux using the command line, you can use the find command. The find command is a powerful tool that allows you to search for files and directories based on various criteria, such as name, type, size, or date modified.

Here’s an example of how to use the find command to search for a folder named “example” in the current directory and its subdirectories:

find . -type d -name "example"

In this example, the . (dot) specifies the starting directory for the search (in this case, the current directory), and the -type d option specifies that we want to search for directories (as opposed to files). The -name "example" option specifies the name of the directory we’re searching for.

If the directory you’re searching for has a specific parent directory, you can specify that directory as the starting directory for the search. For example, to search for the “example” folder in the /home directory and its subdirectories, you can use the following command:

find /home -type d -name "example"

The find command will return a list of all directories matching the specified criteria. If there are multiple matches, the results will be displayed one per line. If the search was successful and the directory was found, the full path to the directory will be displayed.

Note: The find command is case-sensitive, so if the folder name is “Example” with a capital “E”, you will need to search for “Example” instead of “example”.

Leave a Comment