Poor-mans recursive grep in recursive bash script find grep $ find -type f -exec grep -IH 'word' ,".") -H to output filename where match is found.-r for recursive search down from current directory.$ printf "A-well-a don't you know about the bird?\nWell, everybody knows that the bird is a word" | grep -noP '\bbird\b' Here, for example, we can use -P in grep to make use of Perl regular expressions to surround it. If we're talking about a word as string that could appear in the beginning or end of line, or alone on the line, or surrounded by spaces and/or punctuation - that's when we'll need regular expressions, and especially those that come from Perl. One should note,however,that searching for word can get a little complex, because most line-matching tools will try to find a word anywhere on the line. Here's an overview of different methods that one can use for searching files for specific strings of text, with a few options added specifically to work only with text files, and ignore binary/application files.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |