$a=df|grep vda1|awk '{print $5}'
Above is a typical error in Bash programming for bash newbies, especially for savvy programmers familiar with other languages but bash.
There are two errors in it.
The first is the programmer takes it for granted that the pipeline “df|grep vda1|awk ‘{print $5}'” will be executed and the result is saved in variable a. This is not a correct assumption. Bash will not execute the commands after =, automatically. If you want the command(pipeline) to be executed, you should enclose it with “. So, you should write: `df|grep vda1|awk ‘{print $5}’`.
The second error is you should not use the symbol $ before a variable name in variable assignment. Using the variable name is enough. The dollar symbol is used in situation where you want to expand the variable name to its content.
So, the correct syntax of the above statement is:
a=`df|grep vda1|awk '{print $5}'`