June 2017
Beginner
502 pages
11h 26m
English
As we said before, variables have no type in shell, and this makes them somehow easy to use, but we must pay attention to some sorts of limits to their use.
gzarrelli:~$ cat disk-space.sh #!/bin/bash echo -e "\n" echo "The space left is ${disk_space}" disk_space=`df -h | grep /$ | awk '{print $4}'` echo "The space left is ${disk_space}
We used the variable disk space to store the result of the df command and try to reference its value on the preceding and following lines. Let us run it in debug mode:
gzarrelli:~$ sh -x disk-space.sh + echo -e \n-e + echo The space left is The space ...
Read now
Unlock full access