Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Command Line Fundamentals

You're reading from   Command Line Fundamentals Learn to use the Unix command-line tools and Bash shell scripting

Arrow left icon
Product type Paperback
Published in Dec 2018
Publisher
ISBN-13 9781789807769
Length 314 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Vivek Nagarajan Vivek Nagarajan
Author Profile Icon Vivek Nagarajan
Vivek Nagarajan
Arrow right icon
View More author details
Toc

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image