mirror of
https://github.com/wader/fq.git
synced 2024-12-18 19:01:34 +03:00
c93301fc70
raw format was a hack to skip decoding to be able to get a binary using tobyte etc. Now you can do fq -d bytes ... instead of fq -d raw 'tobytes | ...'
419 B
419 B
Decode to a slice and indexable binary of bytes.
Slice out byte ranges
$ echo -n 'hello' | fq -d bytes '.[-3:]' > last_3_bytes
$ echo -n 'hello' | fq -d bytes '[.[-2:], .[0:2]] | tobytes' > first_last_2_bytes_swapped
Slice and decode byte range
$ echo 'some {"a":1} json' | fq -d bytes '.[5:-6] | fromjson'
{
"a": 1
}
Index bytes
$ echo 'hello' | fq -d bytes '.[1]'
101