Bash Script store cat output in variable and then echo it

bash, unix

Solution

Variable assignments in bash should not have any spaces before or after the equal sign. It should be like this:

#!/bin/bash
var=$(cat tmp/pids/unicorn.pid)
echo "$var"

Which can be written more idiomatically as

#!/bin/bash
var=$(< tmp/pids/unicorn.pid)
echo "$var"

Problem

I am trying to store a cat output into a variable and then trying to echo it. and then I would like to kill the process. ``` #!/bin/bash var = $(cat tmp/pids/unicorn.pid) echo $var sudo kill -QUIT $var ``` Please if anyone can tell where I am going wrong

Original source

Related problems