Storing openssl file digest as shell variable?
问题 I am executing the below command in bash filehash=`openssl dgst -sha1 $filename` When I echo $filehash I get this SHA1(myfile.csv)= bac9c755bac9709fa8966831d1731dff07e28e6c How do I only get the hash value stored and not the rest of the string i.e. bac9c755bac9709fa8966831d1731dff07e28e6c Thanks 回答1: Through sed , filehash=`openssl dgst -sha1 $filename | sed 's/^.*= //'` It removes all the characters upto the = (equal symbol followed by a space). 回答2: In a lot of ways with pure Bash, e. g. by