These are some of the useful commands to search files in linux system.
Consider we need to list all the mp3 files in our system. Use the following command
find / -name *.mp3
Now, we need to find a file which has the name in which some letters are s and e
find / -name *se*
if we need to search in a particular folder, just include the folder path
find Softwares/ -name *se*
Find command is useful but it will take some time to search the system if it contains too many files. Locate is a very simple and powerful command which can be used in place of find.
To find the file abc.txt command is
locate abc.txt
it will scan the system and list the locations where abc.txt is present.
Now, if we need to search in a specific directory just include the folder name.
locate Softwares/ *.txt
okay then why we should use locate command ? both yields the same result..
Its because locate command is too faster than find command. The reason for that is, there is a background process that runs on your system that essentially finds new files and stores them in a database. when you use the locate command, it then searches the database instead of searching your filesystem while you wait.
Consider we need to list all the mp3 files in our system. Use the following command
find / -name *.mp3
Now, we need to find a file which has the name in which some letters are s and e
find / -name *se*
if we need to search in a particular folder, just include the folder path
find Softwares/ -name *se*
Find command is useful but it will take some time to search the system if it contains too many files. Locate is a very simple and powerful command which can be used in place of find.
To find the file abc.txt command is
locate abc.txt
it will scan the system and list the locations where abc.txt is present.
Now, if we need to search in a specific directory just include the folder name.
locate Softwares/ *.txt
okay then why we should use locate command ? both yields the same result..
Its because locate command is too faster than find command. The reason for that is, there is a background process that runs on your system that essentially finds new files and stores them in a database. when you use the locate command, it then searches the database instead of searching your filesystem while you wait.
Post a Comment