Read result of sha256sum into a bash variable

This question already has an answer here:

  • How to set a variable to the output of a command in Bash? 13 answers

  • You don't need store it in a variable. You can directly redirect it to the file as well.

    sha256sum  debug_2.0.5.hex | awk '{print $1}' > dsl
    

    If you do need to store it in a variable for some other purpose then:

    read -r shm_id rest <<<"$(sha256sum  scr)"
    echo $shm_id > dsl
    

    or

    shm_id=$(sha256sum  scr | awk '{print $1}')
    
    链接地址: http://www.djcxy.com/p/57214.html

    上一篇: 将LFTP结果输出到变量

    下一篇: 将sha256sum的结果读入bash变量