Demonstrating the use of scripts
Here is an example of a very simple script. It might not look like much but this is the basis for every script:
Chapter 1 - Script 1
#!/bin/sh # # 03/27/2017 # exit 0
Note
By convention, in this book the script lines will usually be numbered. This is for teaching purposes only, in an actual script the lines are not numbered.
Here is the same script with the lines numbered:
1 #!/bin/sh 2 # 3 # 03/27/2017 4 # 5 exit 0 6
Here is an explanation for each line:
- Line 1 tells the operating system which shell interpreter to use. Note that on some distributions
/bin/sh
is actually a symbolic link to the interpreter. - Lines that begin with a
#
are comments. Also, anything after a#
is also treated as a comment. - It is good practice to ...
Get Linux Shell Scripting Bootcamp now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.