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)

Shell Expansion

The basic concept of shell expansion is that the shell substitutes certain expressions that have been typed on the command line with some expanded text. In earlier chapters, we learned to use shell expansion constructs such as wildcards and escape sequences. In this topic, we will learn about several more mechanisms for expansions that the shell provides.

Environment Variables and Variable Expansion

Environment variables in Bash are similar in function to variables in most programming languages; they are names to which values are associated. An environment variable is initialized with the following syntax:

VARNAME=VALUE

There is no space on either side of the equals symbol, and the value follows the same rules of the shell as those with respect to quoting, escape sequences, and wildcards (and other expansions). The value of an environment variable is expanded with the $ symbol, as shown here:

robin ~ $ ANSWER=42
robin ~ $ echo The answer is &quot...