Questions
This time, instead of presenting you with questions to answer, I’ll present you with some buggy shell scripts. Try running them to observe the errors, and then try to debug them. Can you debug them? Sure you can. I have faith in you.
- We’ll start with the
bug1.sh
script:#!/bin/bash echo "Fix this script...I've got bugs" a=45 if [$a -gt 27 ] then echo $a fi exit
- Here’s the
bug2.sh
script:#!/bin/bash echo "Fix this script...I've got bugs" for i in 1 2 3 4 5 6 7 8 9 do echo $i exit
- Now, for
bug3.sh
:#!/bin/bash echo "Fix this script...I've got bugs" scripts=$(ls | grep [a-z]*.sh) echo $scripts exit
- Here’s the fourth and final,
bug4.sh
:#! /bin/bash echo '1 2 3' > sample.data cut -d' ' -f1,3 sample.data | read x z echo $((x+z))