Is there a way to find a string or phrase recursively in all files in a folder from the command line, such that the output would be similar to Sublime Text 2's find behavior? Like, with the path of the filename that the string has been found in and some of the text block that contains it?
I will assume you are using a *nix system. If you just want the files in the current folder, do
$ grep -C 3 foo * bar.txt-This is line one bar.txt:This is line two, which contains foo bar.txt-This is line 3
If you also want to recurse into subfolders, use
grep -rC 3 foo
grep, egrep, fgrep, rgrep - print lines matching a pattern -C NUM, -NUM, --context=NUM Print NUM lines of output context. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given. -R, -r, --recursive Read all files under each directory, recursively; this is equivalent to the -d recurse option.