SYNOPSIS
mlr [options] {verb} [verb-options] {input-file}FLAGS
| FLAG | LONG FORM | DESCRIPTION |
|---|---|---|
| --csv | — | Read/write CSV format |
| --tsv | — | Read/write TSV format |
| --json | --j | Read/write JSON format |
| --j2c | — | JSON input, CSV output |
| --c2j | — | CSV input, JSON output |
| --nidx | — | Numerically indexed fields (like awk) |
| -I | — | In-place file editing |
| --from | — | Specify input file explicitly |
| --fs | --field-separator | Set field separator |
| --rs | --record-separator | Set record separator |
EXAMPLES
#ex-01Filter rows where age > 30
mlr --csv filter '$age > 30' data.csv
OUTPUT
name,age,city Alice,34,Boston Marcus,41,Denver
#ex-02Sort by field name, then age descending
mlr --csv sort -f name -r age data.csv
#ex-03Rename fields
mlr --csv rename 'first_name,name,last_name,surname' data.csv
#ex-04Convert JSON to CSV
mlr --j2c cat data.json > output.csv
#ex-05Compute stats per group
mlr --csv stats1 -a mean,min,max -f salary -g department data.csv
OUTPUT
department,salary_mean,salary_min,salary_max Eng,112000,85000,145000
#ex-06Add computed field
mlr --csv put '$bmi = $weight / ($height ** 2)' data.csv
#ex-07Chain multiple verbs
mlr --csv filter '$active == "true"' then sort -f name then cut -f name,email data.csv
SEE ALSO:awkjqcsvkitxsv
SYNOPSIS
jq [options] <filter> [file...]
FLAGS
| FLAG | LONG FORM | DESCRIPTION |
|---|---|---|
| -r | --raw-output | Output raw strings, not JSON texts |
| -c | --compact-output | Compact output (no pretty-print) |
| -n | --null-input | Use null as input; useful for constructing JSON |
| -e | --exit-status | Exit 1 if last output is false or null |
| -s | --slurp | Read all inputs into an array |
| -R | --raw-input | Read each line as a string |
| -C | --color-output | Force colorized JSON output |
| -f | --from-file | Read filter from file |
| --arg | — | Pass a string argument to the filter |
| --argjson | — | Pass a JSON argument to the filter |
EXAMPLES
#ex-01Pretty print JSON
cat data.json | jq '.'
OUTPUT
{
"users": [...]
}#ex-02Extract all user names
jq '.users[].name' data.json
OUTPUT
"Alice" "Marcus" "Priya"
#ex-03Filter array by condition
jq '[.[] | select(.active == true)]' data.json
#ex-04Transform keys to lowercase
jq 'with_entries(.key |= ascii_downcase)' data.json
#ex-05Merge two JSON files
jq -s '.[0] * .[1]' base.json override.json
#ex-06Count array elements
jq '.users | length' data.json
OUTPUT
42
#ex-07Output as CSV (raw)
jq -r '.users[] | [.name, .email, .role] | @csv' data.json
OUTPUT
"Alice","alice@corp.io","admin"
#ex-08Recursive descent — find all keys
jq '[.. | objects | keys[]] | unique' data.json
SEE ALSO:yqfxgronmlr
SYNOPSIS
grep [OPTIONS] PATTERN [FILE...]
FLAGS
| FLAG | LONG FORM | DESCRIPTION |
|---|---|---|
| -r | --recursive | Recursively search subdirectories |
| -n | --line-number | Print line number with output |
| -i | --ignore-case | Case-insensitive matching |
| -v | --invert-match | Select non-matching lines |
| -l | --files-with-matches | Print only filenames with matches |
| -c | --count | Print count of matching lines per file |
| -A | — | Print N lines of trailing context after match |
| -B | — | Print N lines of leading context before match |
| -C | — | Print N lines of context around match |
| -E | --extended-regexp | Use extended regex (ERE) |
| -P | --perl-regexp | Use Perl-compatible regex (PCRE) |
| -o | --only-matching | Print only the matched part |
| -q | --quiet | Suppress output; exit 0 if match found |
| -w | --word-regexp | Match whole words only |
EXAMPLES
#ex-01Basic string search
grep "error" /var/log/syslog
OUTPUT
Jun 11 04:22:18 kernel: error: device not found
#ex-02Recursive search with line numbers
grep -rn "TODO" ./src/
OUTPUT
./src/main.ts:42: // TODO: refactor this
#ex-03Invert match — exclude comment lines
grep -v "^#" /etc/ssh/sshd_config
#ex-04Case-insensitive, count per file
grep -ri -c "password" ./configs/
OUTPUT
./configs/app.conf:3 ./configs/db.conf:1
#ex-05Perl regex — find IP addresses
grep -P '\b(?:\d{1,3}\.){3}\d{1,3}\b' access.logOUTPUT
192.168.1.105 - GET /api/v2/users 200
#ex-06Context lines around match
grep -n -C 3 "CRITICAL" app.log
#ex-07Only matching text (useful with regex)
grep -oP 'user=\K[^ ]+' auth.log
OUTPUT
root admin deployer
#ex-08Files containing match only
grep -rl "SECRET_KEY" ./
OUTPUT
./config/secrets.py ./.env.local
#ex-09Word boundary match
grep -w "root" /etc/passwd
OUTPUT
root:x:0:0:root:/root:/bin/bash
SEE ALSO:ripgrepagacksedawk
SYNOPSIS
awk [options] 'program' [file...]
FLAGS
| FLAG | LONG FORM | DESCRIPTION |
|---|---|---|
| -F | — | Set field separator (e.g. -F: for colon) |
| -v | — | Assign a variable before program executes |
| -f | — | Read awk program from file |
| -i | — | In-place editing (GNU awk) |
| NR | — | Number of records (current line number) |
| NF | — | Number of fields in current record |
| FS | — | Field separator (default: whitespace) |
| OFS | — | Output field separator |
| RS | — | Record separator (default: newline) |
| ORS | — | Output record separator |
EXAMPLES
#ex-01Print second field of each line
awk '{print $2}' file.txt#ex-02Sum a column
awk '{sum += $3} END {print "Total:", sum}' data.txtOUTPUT
Total: 48291
#ex-03Filter lines by field value
awk -F: '$3 == 0 {print $1}' /etc/passwdOUTPUT
root
#ex-04Print lines between patterns
awk '/START/,/END/ {print}' logfile.txt#ex-05Reformat CSV output
awk -F, 'NR>1 {printf "%-20s %s\n", $1, $3}' data.csv#ex-06Count occurrences of each value
awk '{count[$1]++} END {for (k in count) print k, count[k]}' file.txtSEE ALSO:sedgrepmlrperl
SYNOPSIS
sed [options] script [input-file...]
FLAGS
| FLAG | LONG FORM | DESCRIPTION |
|---|---|---|
| -n | --quiet | Suppress automatic printing of pattern space |
| -e | — | Add the script to commands to be executed |
| -f | — | Read script from file |
| -i | — | Edit files in-place (with optional backup suffix) |
| -r | --regexp-extended | Use extended regular expressions |
| s/x/y/ | — | Substitute: replace x with y (first occurrence) |
| s/x/y/g | — | Substitute: replace all occurrences |
| d | — | Delete matching lines |
| p | — | Print matching lines (use with -n) |
| a\ | — | Append text after matching line |
EXAMPLES
#ex-01Replace first occurrence per line
sed 's/foo/bar/' file.txt
#ex-02Replace all occurrences, in-place
sed -i 's/old_domain/new_domain/g' config.conf
#ex-03Delete blank lines
sed '/^$/d' file.txt
#ex-04Print lines matching pattern
sed -n '/ERROR/p' app.log
#ex-05Delete lines 5 through 10
sed '5,10d' file.txt
#ex-06Insert line before match
sed '/^\[server\]/i # Auto-generated config' nginx.conf
SEE ALSO:awkgrepperltr