2

I've got a curl command like so:

curl -v --silent --tlsv1.1 https://google.com/ 2>&1 | grep TLS

I'd like to capture the output of that command in a variable. Normally I'd use a subshell to do this, but it doesn't seem to work.

Here's what I'm trying to do:

OUT=$(curl -v --silent --tlsv1.1 https://google.com/ 2>&1 | grep TLS)
echo $OUT

but the command outputs the following (if I'm in a directory with a single file in it called "UNEXPECTED.TXT").

UNEXPECTED.TXT TLS 1.0 connection using TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA

So it seems to do a directory listing of the current directory, then append my output to the end of that.

Thanks!

1 Answer 1

2

Use quotes:

echo "$OUT"
* TLS 1.1 connection using TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA

Since variable OUT has a starting *, without quotes shell is expanding first * to all the files/directories in your current path and listing all the files/directories.

Sign up to request clarification or add additional context in comments.

1 Comment

Ahhh... That makes sense! Thanks!

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.