Bash operator translation to fish

bashfishio-redirection

I've been trying to learn to use jq and for bash it uses the <<< operator which I cannot understand after reading the bash documentation, what is this operator for?

Besides that, I use the fish shell instead. How can I translate jq . <<< '{"some": "xyz"}' (works in bash) to the fish shell?

Best Answer

The <<< operator is a here-string

3.6.7 Here Strings

Given:

[n]<<< word

The word undergoes brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, and quote removal. Pathname expansion and word splitting are not performed. The result is supplied as a single string, with a newline appended, to the command on its standard input (or file descriptor n if n is specified).

To translate this to fish shell you could likely do:

echo '{"some": "xyz"}' | jq

(which would work in bash as well)

Related Question