Book Image

Command Line Fundamentals

By : Vivek Nagarajan
Book Image

Command Line Fundamentals

By: Vivek Nagarajan

Overview of this book

The most basic interface to a computer—the command line—remains the most flexible and powerful way of processing data and performing and automating various day-to-day tasks. Command Line Fundamentals begins by exploring the basics, and then focuses on the most common tool, the Bash shell (which is standard on all Linux and iOS systems). As you make your way through the book, you'll explore the traditional Unix command-line programs as implemented by the GNU project. You'll also learn to use redirection and pipelines to assemble these programs to solve complex problems. By the end of this book, you'll have explored the basics of shell scripting, allowing you to easily and quickly automate tasks.
Table of Contents (6 chapters)

Command Lists

Command lists are a mechanism used to execute multiple independent commands at once, either sequentially or concurrently. Sequentially, they can be used to run each command one after another (simple sequential execution) or run each command depending on the success or failure of the previous one (dependent execution). However, before we understand how command lists work, we need to learn the concept of exit codes.

When any program or command exits, it returns a number, called the exit code, to the shell. This number is zero if the command completes successfully and non-zero otherwise. Exit codes are also sometimes referred to as return values.

Command List Operators

Command lists are formed by stringing together commands with an operator in between, such as the ; operator, & operator, and the && or || operators. Now, let's look at each of these operators in detail.

Semicolon Operator

The ; operator is quite simple and is used to execute...