storing a value from another file as a variable[solved]

Hi all, im having snags creating a variable which uses commands like cut and grep. In the instance below im simply trying to take a value from another file and assign it to a variable. When i do this it only prints the $a rather than the actual value. I know its simple but does anyone have any ideas?

a='cut -f2 money'

echo $a

---------- Post updated at 02:41 PM ---------- Previous update was at 02:33 PM ----------

no need to worry iv just figured it out

Try backticks:

a=`cut -f2 money`

or this:

a=$(cut -f2 money)

If the result of the cut is more than 1 value, you want to surround both lines of code with doubel quotes like:

a="$(cut -f2 money)"
1 Like