Forrest logo
back to the mlr tool

mlr:tldr:ead79

mlr: Filter lines of a compressed CSV file treating numbers as strings.
$ mlr --prepipe 'gunzip' --csv filter -S '$${fieldName} =~ "${regular_expression}"' ${example-csv-gz}
try on your machine

The command is using the mlr tool to filter a CSV file that has been compressed with gzip.

Here is the breakdown of the command:

  • mlr: This is the command to invoke the mlr tool, which stands for "Miller". Miller is a command-line tool for processing and manipulating structured text files, like CSV.

  • --prepipe 'gunzip': This option specifies that the input file should first be decompressed using gunzip. So, the input file, which is specified as ${example-csv-gz}, is expected to be a gzip-compressed CSV file.

  • --csv: This option informs mlr that the input file is in CSV format.

  • filter -S '$${fieldName} =~ "${regular_expression}"': This is the filtering operation being applied by mlr. The filter command is used to selectively include or exclude records from the input data. The -S flag is used to preserve the input order of records.

    Inside the single quotes, the filter expression is specified. The ${fieldName} is a placeholder for a field name in the input data which you need to replace with an actual field name. The =~ operator is the "matches-regex" operator, which checks if the field value matches the specified regular expression ${regular_expression}.

  • ${example-csv-gz}: This is the path or filename of the input file. It should be replaced with the actual path or filename of your gzip-compressed CSV file.

In summary, the command takes a gzip-compressed CSV file as input, decompresses it, and filters the records based on a specified field name and regular expression.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the mlr tool