How to Find a File by Name Using Command Line in Ubuntu
find
You can use the find command to find or search for a file in a directory hierarchy.
For example, to find the file named "sample.txt" within the /var/www you can use:
/var/www
To search this file within the whole file system you can simply use:
To search this file within the current working directory you can use:
The options have the following meanings:
-type
f
-name
Moreover, if you want to search for a directory use the option -type d.
-type d
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Use the
find
CommandYou can use the
find
command to find or search for a file in a directory hierarchy.For example, to find the file named "sample.txt" within the
/var/www
you can use:To search this file within the whole file system you can simply use:
To search this file within the current working directory you can use:
The options have the following meanings:
-type
: Search for files based on their type. The descriptorf
specify a regular file.-name
: Sets the name of the file you are searching for.Moreover, if you want to search for a directory use the option
need an explanation for this answer? contact us directly to get an explanation for this answer-type d
.