Hardware Reference
In-Depth Information
A shell script is simply a collection of commands, each exactly as you would type them at the
console or terminal. Each command is run in order, from top to bottom, but it's also possible
to use loops as in programming languages like Scratch and Python (see Chapter 11, “An
Introduction to Scratch” and Chapter 12, “An Introduction to Python” for more details).
Coupled with the shell's ability to chain multiple programs together, shell scripting is a pow-
erful tool.
To start a shell script, simply create a new text file in your current directory with the follow-
ing command:
nano timelapse.sh
The extension .sh is traditionally used for shell scripts, although it's not strictly necessary.
Using a file extension like this helps you to remember the difference between a shell script
and an executable program, so it's certainly recommended.
At the top of the file (see Figure 15-8) enter a line that tells the operating system to interpret
the commands using the default Bash shell:
#!/bin/bash
Figure 15-8:
Editing the
timelapse.
sh script in the
nano editor
 
Search WWH ::




Custom Search