![]() ![]() type f -name "*.java" -exec grep -il 'foo' \ įinally, if your know the string is in a file in the current directory there's no need to use the find command. ![]() When this happens, and other search means like the "locate" command don't help, my favorite way of searching for text strings in files that are spread through a bunch of directories and sub-directories is this:įind. Find Files Containing Specific Text in Linux, To search for a specific string in all files located inside specific directory recursively, use the following syntax: grep -r 'search-string' '/path-of-the-directory' For example, find all files that containing string called ubuntu in the directory /mnt/grub.d recursively, run the following. If you want to print only file names and hide the text from the output. Find File Names That Contains a Given String. Now to search and find all files for a given text string in a Linux terminal, you. Linux find/grep FAQ: How can I combine the Linux find and grep commands to search a large collection of files?Ī lot of times when I need to find a file I know the text in the file that I'm looking for, but I can't remember the filename, or can't think of what directory it might be in, other than somewhere below my home directory. Search Specific Text in Linux Using Grep Command Search for Particular Text in Files.
0 Comments
Leave a Reply. |