0

I try to echo the output of curl in a pipe: I tried

curl -s --fail --compressed -u $CREDS -X GET URL | echo * | jq -S "." > file.txt

curl -s --fail --compressed -u $CREDS -X GET URL | echo | jq -S "." > file.txt

curl -s --fail --compressed -u $CREDS -X GET URL | xargs echo | jq -S "." > file.txt

But they all didn't work. What am I doing wrong?

1
  • Remove | echo part. Didn't work is not a problem description. Please include example input and example and expected output. Commented Nov 30, 2018 at 8:47

1 Answer 1

1

Instead of echo use tee.

curl -s --fail --compressed -u $CREDS -X GET URL | tee - | jq -S "." > file.txt

man page:

NAME tee - read from standard input and write to standard output and files

SYNOPSIS tee [OPTION]... [FILE]...

DESCRIPTION Copy standard input to each FILE, and also to standard output.

   -a, --append
          append to the given FILEs, do not overwrite

   -i, --ignore-interrupts
          ignore interrupt signals

   If a FILE is -, copy again to standard output.
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but now I got: parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 19, column 3 tee: -: I/O error
@mealesbia Unless curl ... | jq -S "." fails to raise the same error, that's an unrelated question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.