First steps
After getting some background information on Linux, preparing our system, and getting an overview of important concepts for scripting in Linux, we have finally arrived at the point where we will be writing actual shell scripts!
Â
To recap, a shell script is nothing more than multiple Bash commands in sequence. Scripts are often used to automate repetitive tasks. They can be run interactively or non-interactively (meaning with or without user input) and can be shared with others. Let's create our Hello World
script! We'll create a folder in our home
directory where we will store all scripts, sorted by each chapter:
reader@ubuntu:~$ ls -l total 4 -rw-rw-r-- 1 reader reader 0 Aug 19 11:54 emptyfile -rw-rw-r-- 1 reader reader 23 Aug 19 11:54 textfile.txt reader@ubuntu:~$ mkdir scripts reader@ubuntu:~$ cd scripts/ reader@ubuntu:~/scripts$ mkdir chapter_07 reader@ubuntu:~/scripts$ cd chapter_07/ reader@ubuntu:~/scripts/chapter_07$ vim hello-world.sh
Next, in the vim
screen, enter the...