Welcome to our shell scripting tutorial series! It's required that you have a basic knowledge of the Linux Command Line, so be sure to review it before you proceed.
A shell script is a file containing lines of code for the shell to execute. The shell reads each line as if you typed them in one at a time into the terminal.
Scripting languages are interpreted, meaning that they aren't compiled into machine language. This results in less efficiency, but in exchange, we are able to more easily write our scripts.
The scripts may be written in any text editor, so simply select one with syntax highlighting - you may use Vim within your terminal, or something like Sublime Text.
We recommend that you learn a text editor while learning shell scripting. Additionally, if you want to try out Vim, head on over to our in-browser Vim tutorial series, or type
vimtutor into the command line. Taking the time to learn Vim keys will speed up your workflow immensely.
Remember that shell scripts should be short and used to manipuate files and commands. If you find that you're writing something that looks overly complex, and involves a slew of string or arithmetic operations, look into a better-suited scripting language such as Python or Perl.
For this module, we'll be using both the command line and shell scripts to give examples of what we're learning.
Anything that comes after a
$ is considered a command to be typed out on the command line. Anything following a
> symbol is a continuation of the line before.
Comment and explanation lines preceed with a
$ cd ~ # Change to home directory $ echo "Anything proceeding a > \ > symbol means it's a continuation \ > of the line before." Anything proceeding a > symbol means it's a continuation of the line before.
Lastly, anything without a preceding special character will be a snippet from a shell script file.
echo 'This is a snippet from a shell script'
Great start! Now let's move on to some important symbols covered in shell scripting.
In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.$ Check price
This foam seat cushion relieves lowerback pain, numbness and pressure sores by promoting healthy weight distribution, posture and spine alignment. Furthermore, it reduces pressure on the tailbone and hip bones while sitting. Perfect for sitting on the computer desk for long periods of time.$ Check price