gertees.blogg.se

Grep command to search files containing a string
Grep command to search files containing a string





grep command to search files containing a string

-type f specifies that you are looking for files.-name “ *.*” : for all files ( -name “ *.pas” -o -name “ *.dfm” ) : Only the *.pas OR *.dfm files, OR specified with -o.in the find specifies from the current directory.

grep command to search files containing a string

type f \( -name "*.pas" -o -name "*.dfm" \) -print0 | xargs -null grep -with-filename -line-number -no-messages -color -ignore-case "searchtext" type f -name "*.*" -print0 | xargs -null grep -with-filename -line-number -no-messages -color -ignore-case "searthtext"Īnd if you have an idea what the file type is you can narrow your search down by specifying file type extensions to search for, in this case. You can use different options of find to improve your file search.Įxpanding the grep a bit to give more information in the output, for example, to get the line number in the file where the text is can be done as follows: find. When I was looking up how to do this, I came across this solution twice: find / -type f -exec grep -H 'text-to-find-here' \ Just to clarify, I’m looking for text within the file, not in the file name.

grep command to search files containing a string

I’m trying to find a way to scan my entire Linux system for all files containing a specific string of text.







Grep command to search files containing a string