O'Reilly logo

CompTIA Linux+ Certification Guide by Philip Inshanally

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The basics of shell scripting

On the command line, we often work with a series of the same commands on a regular basis. It would be ideal to somehow bundle those commands and simplify the process, executing a single command or script to accomplish an overall objective that would take longer if we had to type out a single command repetitively. This is where shell scripting shines. We can place our commands, regardless of how long they may be, into a single file; give it an appropriate name; and execute the script as needed. The following code shows the basic syntax for creating a shell script:

#! /bin/sh

The preceding command is the first line in the script; it is used to define the shell interpreter. The first characters, #!, are often known ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required