Section 6.7. Command Substitution


[Page 222 (continued)]

6.7. Command Substitution

In addition to the older method of command substitutionsurrounding the command with grave accentsBash allows you to perform command substitution using the syntax in Figure 6-23.

Figure 6-23. Command substitution in Bash.

$( command )


Note that the $ that immediately precedes the open parentheses is part of the syntax, and is not a prompt. Here's an example:

$ echo there are $(who | wc -l) users on the system there are 6 users on the system $ _ 


To substitute the contents of a file into a shell command, you may use $(<file) as a faster form of $(cat file).




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net