![]() ![]() The first scenario which we will cover is where in you have to grep for a string inside all sub-directories. Thanks to Johnsyweb who initially brought this up I chose Viveks answer because it provides a general grep solution as asked in the original question. Grep for string in a file recursively inside all sub-directories. ![]() If you have the latter you could run: zgrep 'pattern' -r -format=gz /path/to/dirĪnyway, as suggested, find + zgrep will work equally well with either version of zgrep: find /path/to/dir -name '*.gz' -exec zgrep - 'pattern' \ īut there's a major downside: you won't know where the matches are as there's no file name prepended to the matching lines. If the -r or -R option is specified and a symbolic link referencing a file of type directory is specified on the command line, grep will search the files of the. Since I was essentially doing a search specifically in a git-tracked directory, git grep is apparently much simpler and more apt tool for the job. Is the wrapper script, zgrep (zutils) 1.3 chix' xargs grep -i -n patterntosearch Share Improve this answer Follow answered at 19:54 Sandeep Singh 1,582 2 11 10 +1 That's what I use as well Andy White at 19:55 That won’t work if the filenames have spaces in them. Running zgrep -version | head -n 1 will reveal which one (if any) of them is the default: zgrep (gzip) 1.6 5 Answers Sorted by: 7 Recursive grep on Solaris: find. The latter is a c++ program and it supports the -r, -recursive option. tqdm works on any platform (Linux, Windows, Mac, FreeBSD, NetBSD, Solaris/SunOS), in any console or in a GUI, and is also friendly with IPython/Jupyter. It doesn't support the -r, -recursive switch. The former is just a wrapper script that calls gzip -cdfq. ![]() I have two versions on my system, zgrep from gzip and zgrep from zutils. r means to recurse texttofind is the string to search for The dot simply means start the search from the current working directory. There's a lot of confusion here because there isn't just one zgrep. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |