Searching files directories and content in Linux
Posted By : Mohd Sheemal | 23-Sep-2017
First I check all the files or folders present in the current location with the help of ' ls ' command.
There are following commands we have to check the files, content, and folders are :
- grep
- find
- locate
- Grep: The grep command can be used to find out and can search content inside a file.
. To filter the folder hierarchy based on the
Syntax of the command is: grep 'search text' filename
Example: We are using grep command to find text Testing inside the file log1.txt, with the help of grep command we can search content inside a file. If we have a big log file and I want to check the file of the content, where my Testing is written, we can directly go to the grep command.
Grep Testing log1.txt
- Find: The find command is used to, If the current location we have a lot of files and folders (directories) and I want to check a particular file
Syntax of the command is: find filename
If this file exists in the current folder or directories, It will display that and If we find any file - example: file1.txt, If this file does not exist so It is not going to give any file. It will display the message
- Locate: The locate command is used to search in the complete system. If I want to check all the files or folders which exist in my system where the name is Log. It will display all the results with respect to Log.
. The locate command is used too often the simplest and the quickest way to finding the locations of the filed & folders on Linux
Syntax of the command is: locate file/folder name
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Mohd Sheemal
Mohd Sheemal is a Bright QA Engineer. He has a good knowledge over Selenium.