From the course: LPI Linux Essentials (010-160) Cert Prep
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Variables - Linux Tutorial
From the course: LPI Linux Essentials (010-160) Cert Prep
Variables
Let's talk a little more about variables. Now, in addition to inputting a variable as part of the arguments for a script, you can also assign the variable within the script itself using the output of another command. These variables are identified by a leading dollar sign, but they're given a typical name that's easier to be read, something that begins with a letter. Where in the last lesson, we used dollar sign one, dollar sign two, as the first and second parameters. In this case, we're going to use dollar sign with a word to represent some other variable. These variables an be used together with normal commands as if they were command parameters as well, but the value of the variable is going to be past that command. Let's take a look at this script and see how this works in reality. Now, this script is going to check if a router is up by pinging it using the ping utility and two different variables. The first…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Text files and text editors3m 55s
-
Using vi and nano8m 57s
-
(Locked)
Beginning a shell script2m 33s
-
(Locked)
Commands4m 38s
-
(Locked)
Arguments2m 35s
-
(Locked)
Variables3m 24s
-
(Locked)
Conditional expressions4m 39s
-
(Locked)
Loops and functions3m 48s
-
(Locked)
Exit value2m 17s
-
(Locked)
Turning commands into a script11m 39s
-
(Locked)
-
-
-
-
-