Number, so to print lines from a file: $ zq file. It's given the name of theĬompressed file and a list of queries. The zq program is used to query an index. $ zindex file.gz -pipe "jq -raw-output -unbuffered '.orderId.id] | join(\" \")'" Matches separated by spaces (which is the default separator). Line piped to jq creates a single line of output, with multiple OrderId.ids, then joins them with a space to ensure each individual JSON field orderId.id in any of the items in the document root'sĪctions array (requires jq). $ zindex file.gz -regex 'id:(+)' -numeric -uniqueĬreate an index on the second field of a CSV file: $ zindex file.gz -delimiter, -field 2 The capture group indicates the part that's to be indexed,Īnd the options show each line has a unique, numeric index. This can be done by a regular expression, by field, or by piping eachīy default zindex creates an index of file.gz.zindex when asked toĬreate an index on lines matching a numeric regularĮxpression. In this case, the terminal prints the first two matches it finds in the sample file. If you want to search all the files in a directory with grep, use it like this: grep searchterm There is a problem with it. Usually, you run grep on a single file like this: grep searchterm filename. Limit the number of lines in the grep output by adding the -m option and a number to the command. Grep is an excellent tool when you have to search on the content of a file.
Individual files, such as log files, can contain many matches for grep search patterns.
Zindex needs to be told what part of each line constitutes the index. Limit grep Output to a Fixed Number of Lines.
One can follow this workflow to have good performance:
If you use Windows checkt this out about Linux tools in Windows. For someone working with huge text files in Unix/Linux/Mac/Cygwin.