Seemed simple, but not so far. Tried lots of things. Best I've got:
echo "low quality not gonna apologize" | jq -r 'gsub("[\\s+]"; " "; "g")'
parse error: Invalid numeric literal at line 1, column 4
Goal is to have 1 space replace any occurrence of multiple whitespace of any kind. Note that I removed tabs and newlines already from this stream. This is bash shell. I don't get this error in the context of the larger application I'm building either, where the code is simply and quietly not changing the multiple spaces into a single space for IDK why.
The right way with jq:
echo "low quality not gonna apologize" | jq -Rr 'gsub("\\s+";" ";"g")'
-R - raw input; each line of text is passed to the filter as a stringThe output:
low quality not gonna apologize
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With