Join Scott Simpson for an in-depth discussion in this video Working with variables, part of Learning Bash Scripting.
…As with any language, you'll probably find yourself…needing to work with variables in your scripts.…They're named with a sequence of alphanumeric characters…and the names must start with a letter.…To declare a variable, I'll type its name directly…followed with an equals sign, directly followed with a value.…Note that there's no spaces.…If you put spaces around the equals sign,…you'll get an error when you run the script.…Likewise, if your variable is a string with spaces in it, such as…good morning, you'll need to put that…string in quotes in the variable declaration.…Of course, a variable could also be a number, so to use these…variables, we call them with a dollar sign in front of their name.…
So I'll save that, and I'll run it to the command line.…And we can see the values printed out there.…These variables also work inside of other…variables or strings if they're double quoted.…And again I'll save, and run.…And…here I have a string that has variables included in it.…Of course, that can be very handy for generating output to the standard out.…
- What is Bash?
- Managing output with grep, awk, and cut
- Understanding Bash script syntax
- Creating a basic Bash script
- Displaying text with "echo"
- Working with numbers, strings, and arrays
- Reading and writing text files
- Working with loops
- Using functions
- Getting user input during execution
- Ensuring a response
Skill Level Beginner
1. Working with the Command Line
2. Building Bash Scripts
3. Control Structures
4. Interacting with the User
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.