I'm using jq to parse a JSON file as shown here. However, the results for string values contain the "double-quotes" as expected, as shown below:
$ cat json.txt | jq '.name'
"Google"
How can I pipe this into another command to remove the ""? so I get
$ cat json.txt | jq '.name' | some_other_command
Google
What some_other_command
can I use?
cat foo | bar
is significantly less efficient thanbar <foo
or its equivalent<foo bar
, especially ifbar
is a program likesort
that can parallelize its operations when given a seekable file descriptor as opposed to a FIFO (which can only be read once front-to-back). It both means more startup overhead (invoking/bin/cat
), and more context switches between userspace and kernel (each piece of content going through aread()
withincat
, then awrite()
to a FIFO incat
, and then aread()
inside your destination program, instead of skipping to that last step directly). – Charles Duffycat foo | wc -c
, vswc -c <foo
-- in the latter case it can just do two syscalls,seek()
andtell()
, to get the exact size of the file now matter how long it is; in the former, it needs to read to the end, even if that's gigabytes of content, because onlycat
has direct access to the original file, andwc
has no way to request metadata on it. – Charles Duffy