Linux File Search: Possible Solutions

Each operating system has its pros and cons, which are manifested when working. The same goes for Linux. Many users regularly have problems finding files or text entries in the system. However, this problem is quite easy to solve. This article details how Linux searches for file contents.

Search for entries via grep

The appearance of the program at work

The first way to find the file or record you need is the grep utility built into the system. Its name stands for global regular expression print. The appearance of the program is very similar to the command prompt window in Windows. In order to start the search, you need to enter the grep –r "" command in the grep window, where in quotation marks you must specify the approximate name of the desired file or a piece of text. After that, the utility will immediately begin to study libraries in search of data. In grep, searching the contents of files on Linux is pretty slow, so you'll have to wait

Search for executable file through which command

Using a command to lose a file

If the user needs to find an executable program file that he accidentally deleted or lost, the managed command which will come to his aid. For the best search, use the full command /home/username/.local/bin / "...", where you must enter the file name in quotation marks. This command is the easiest way to search the contents of files in Linux.

Finding a file with locate

The last way to find files on Linux is with the locate command. It should be borne in mind that with its help you can find a file only by its exact name, unlike the previous methods. In addition, locate cannot search for text in documents. If the user knows the location of the file, but gets to it far, the command will be welcome. To search, enter locate query "...". The full name of the executable file is indicated in quotation marks.

Any of the methods will help you quickly search the contents of the file. But it is very important not to make a mistake when writing the name on the command line.

Source: https://habr.com/ru/post/K21053/


All Articles