How do I redirect output to a variable in shell? [duplicate] October 6, 2022 by Tarik Use the $( ... ) construct: hash=$(genhash --use-ssl -s $IP -p 443 --url $URL | grep MD5 | grep -c $MD5)