

The first part of the command looks for the word Walden in any files in the current directory, and the second runs another grep command on the results of the first command. Once you get a regex the way you want it, there is a Copy button (not shown in. You’d use this command: grep Walden * | grep Pond. I used the pattern main(String a-z with the grep utility described. This option treats the pattern you used as an extended regular expression.
However if you just interested in finding out lines with dd pattern, try: grep dd

Say you want to find files containing both Walden and Pondon the same line. The latest way to use grep is with the -E option. In regex: character means, start of data line. Using the pipe ( |), a Unix redirection operator, you can tell grep to search for more than one string. (Note that you can also combine options-for instance, grep -rl Walden searches subfolders and returns only a list of files containing the word Walden. Get started with the helpful options listed here. The grep command has several options that let you fine-tune the way you search for text, as well as the kind of results grep returns. You need to quote the regex from the shell, or escape the backslash itself so the shell doesnt consume it. Returns the names of files containing Walden and the number of hits in each file. Finds Walden in any file in any subfolder of ~/Documents.įinds only live does not find liver, lives, lived, and so on.įinds files containing Walden, but returns only a list of file names.
