Join Scott Simpson for an in-depth discussion in this video Command substitution, part of Learning Bash Scripting.
…Chances are you'll probably want to get some information back from…Command Z right in the bash script, instead of just running them.…Luckily, it's very easy with command substitution.…That's accomplished using a dollar sign with parentheses around a…command, in this case, PWD, which prints the working directory.…What this does is run the command inside the parentheses, and…assigns the result to the variable specified, in this case, d.…Without the command substitution stuff around PWD, the value would just be P-W-D.…I'll put that back and I'll save the script and then I'll run it.…
So that's a pretty basic example, but let's take a look at another one.…At some point in your script writing adventures, you'll…want to use the value of some complex command.…As an example, let's take a look at finding out…how long it takes to get a response from a server.…You may recognize this command from an earlier movie.…What matters here is that I'm setting the variable…a to the result of this command line statement.…So if I run this command, I see the result.…
- 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.