https://host/path. tjoho
https://host/path.ext tjoho
| # "01:02:03.45" -> 3723.45 | |
| def from_duration: | |
| ( reduce (split(":") | reverse[]) as $p ( | |
| {m: 1, n: 0}; | |
| ( .n = .n + ($p | tonumber) * .m | |
| | .m *= 60 | |
| ) | |
| ) | |
| | .n | |
| ); |
| def from_syslog: | |
| ( split("\n") | |
| | map( | |
| ( capture("^(?<ts>\\w{3}\\s+\\d{1,2} +[\\d:]+) (?<host>\\w+) (?<process>\\w+)\\[(?<pid>\\d+)\\]: (?<message>.*)$") | |
| | .ts |= strptime("%b %d %H:%M:%S") | |
| | .pid |= tonumber | |
| ) | |
| ) | |
| ); |
https://host/path. tjoho
https://host/path.ext tjoho
| def _cvs_named_color_ranges: | |
| { all: [[0,255]] | |
| , ascii: [[0,127]] | |
| , nonascii: [[128,255]] | |
| , null: [[0,0]] | |
| , space: [[9,13]] | |
| , print: [[32,126]] | |
| }; |
| # same as fromstream but with a prefix level, outputs [$prefix_path, $json_value], ... | |
| # Usage: | |
| # cat big | jq -L . --stream -n 'include "stream"; reduce fromstream(inputs; 1) as $pv ({}; $pv as [$p, $v] | .[$v.type] += 1)' | |
| def streaks_by(f; g): | |
| foreach ((g | ["v", .]), ["end"]) as $o ( | |
| { acc: null | |
| , fv: null | |
| , emit: null | |
| }; |
| Was created from https://github.com/wader/vscode-jq/blob/master/syntaxes/jq.tmLanguage.json |
| plutil -convert xml1 file.tmLanguage.json -o file.tmLanguage | |
| Open file.tmLanguage in Sublime and use Tools / Developer / "New Syntax from file.tmLanguage" | |
| A new tab with file.subline-syntax should appear |
| echo '[{"a":123, "b":123, "c": 2},' | jq --stream | jq -s 'reduce (.[] | select(.[1])) as $p ({}; setpath($p[0]; $p[1])?)' |
cat file.txt
grep '' file.txt
awk '/.*/ { print }' file.txt
dd status=none if=file.txt (GNU dd)
curl file://$PWD/file.txt
jq -rRs . file.txt
ffmpeg -v quiet -f data -i file.txt -map 0:0 -c text -f data -| def _chunk($size): | |
| ( range( | |
| ( (length / $size) | ceil | |
| | if . == 0 then 1 end | |
| ) | |
| ) as $i | |
| | .[$i * $size:($i + 1) * $size] | |
| ); |