If you have used windows you well know there is a command name dir and a switch /s to search entire directory and sub-directory for a specific file.
Say you want to search a file incredible.txt in C: drive. type dir/s c:\incredible.txt, it will search for incredible.txt in entire C: drive.
In linux also you can do the same. There is a command find.
Syntax to search from / all the directory and sub-directory
find / -depth -name incredible.txt
/ is the directory from where search begins. It can be any sub-directory also, i.e. /usr/share/
depth option search all sub-directory after searching directory.
name option is for the name of the file to search instead of any other attribute.
Just remember one thing best possible result for search is to search as root user. Searching as normal user may fail into some directory if you don't have access to them. i.e. system directory.
Use of wild card is applicable in find command.
You can use wild card into file name.
Suppose you want to search all files with name starting with file and succeed with anything.
Command will be find / -depth -name file*
No comments:
Post a Comment