

When you normally search without grep -l it prints all files with matching text as well as shown in the following example: I often use grep -iRlto print all the files across directories containing some matching text like hostname, IP Address, or some configuration parameter. The grep -i is for case insensitive search. This option is often used with grep -iR, which recursively searches for files containing matching text in sub-directories as well. Suppress normal output instead, print the name of each inputįile from which output would normally have been printed. Replaced by something more appropriate in those locales.Īnd this is the explanation of grep -l command from grep man page: In other locales, the standard input may be If the standard input is searched, a pathname of (standard input) willīe written, in the POSIX locale. Pathnames are written once per file searched. (The letter ell.) Write only the names of files containing selected This means any investment you made in learning Linux commands like grep will be useful for many years to come.Īnyway, let's understand what does -l option on grep command does here is what the grep -l command option does (from UNIX standard): Linux has already survived for more than 40 years, and I am sure it will remain relevant in the coming years as well. Hence, I also suggest you join one of these online Linux command line courses to learn Linux fundamentals in depth. This option of grep only shows filenames that contain matching text.ītw, a good knowledge of essential Linux commands like find, grep, awk, and sed goes a long way in improving your Linux skills as well as improving your productivity. Since many files contain database references, you might get a lot of data on output, so if you are only interested in all the files containing matching text, you can use the grep -l option.

For example, when you are searching for some configurations like a Linux or database hostname across all configuration files in your application host, then you just want to see which file has contained those references. Still, sometimes you only want to grep to show just filename and path and not the matching text. This is actually required and needed in most situations. It will find all files which match the criteria.The grep command from Linux is one of the powerful commands to find files containing some text, but when you use grep, it not only print the file name but also the line, which is including the matching text. Type the text which the files contain and hit the Enter key. You can specify something like "*.txt" to search for your text in text files only. To find files containing some specific text using Midnight Commander, start the app and press the following sequence on the keyboard:įill in the "File name:" section. Unlike find or grep, mc is not included by default in all Linux distros I've tried. Midnight CommanderĪnother method I often use is Midnight Commander (mc), the console file manager app.

type f -exec grep -l "text to find" \ XFCE4 terminal is my personal preference.įind. To find files containing specific text in Linux, do the following. Also, I find Catfish not useful and prefer classic console tools over it. However, when it comes to the terminal, you cannot use any graphical tool. You need to click on the gear icon and enable the option Search File Contents. To bypass this limitation when working in a GUI session, you can use Сatfish. Сatfish is a popular search tool. However, none of the file managers I've tried allow searching for file contents. In my favorite XFCE desktop environment, the Thunar file manager allows searching for files by typing the file name directly in the file list. If you can use the GUI, searching for files is not a problem.
