Bash - Search Directory Recursively for Term using grep

: ' grep -Rn <needle> <haystack> ' # Find all lines containing "world" in any file and folder under /lib grep -Rn "world" /lib # Search for $foo['bar'] in directory. Notice the escaped characters. grep -Rn "\$foo\['bar'\]" /lib # Context can show you a few lines around the term, # to, you know, give you context grep --context=3 foo myfile.txt

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.