Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Contribute
Contribute
Link to Us
Linux Jobs


More on LinuxToday


Command Substitution in a Bash Shell Script

Feb 08, 2011, 03:04 (0 Talkback[s])

[ Thanks to Andrew Weber for this link. ]

"Command substitution is when you take the output of one command and use it as the argument for another command. If you simply invoke the date utility, you'll get the following output.

date
Fri Jan 19 17:13:29 EST 2007

"That works here, but it might not work well in other cases, like when you're writing a bash script. You would then need to consider using command substitution. There are two ways to do this.

"The first way is the more modern way, and is really the only way that you want to use. You surround the command that you want to substitute with parentheses, and then precede it with a dollar-sign. Here, we're using echo to show the output of date."

Complete Story

Related Stories: