Finding lost files within a computer system with a Linux operating system, with techniques Search for keywords in files

Never had a problem with a file search? We may have experienced this when in need of something while the file name of the file that we will find it forget, while we remember only a few words or writings that exist in the file. In any OS that there is a solution to find the file, not least the linux OS. Inside opreasi linux system we can find the file via commad grep sintax  line. Here’s how we will describe:

Using grep command form (syntax)

grep “text string to search” directory-path

For example search for a string called redeem reward in all text files located in /home/user/*.extentions directory, use
$ grep “where files keyword on file” /home/user/*.extention
Task: Search all subdirectories recursively

You can search for a text string all files under each directory, recursively with -roption:
$ grep -r “where files keyword on file” /home/user/
Task: Only print filenames

By default, grep command prints the matching lines You can pass -H option to print the filename for each match.
$ grep -H -r “where files keyword on file” /home/user/

filename.txt: where files keyword on file

To just print the filename use cut command as follows:
$ grep -H vivek /etc/* -R | cut -d: -f1


1 comment

Leave a comment

Your email address will not be published.