Searches for a String in Input with grep
The grep
command, like find
, is an incredibly powerful search tool in the right hands. Unlike find
, though, grep
processes any text, whether in files, or just in standard input.
The basic usage of grep
is this:
matthew@seymour:~$ grep "some text" *
That searches all files in the current directory (but not subdirectories) for the string some text
and prints matching lines along with the name of the file. To enable recursive searching in subdirectories, use the -r
parameter, as follows:
matthew@seymour:~$ grep -r "some text" *
Each time a string is matched within a file, the filename and the match are printed. If a file contains multiple matches, ...
Get Ubuntu Unleashed 2014 Edition: Covering 13.10 and 14.04,Ninth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.