Substitution Flashcards

1
Q

Back quotes

A

>MYDIR=dirname /usr/local/share/doc/foo/foo.txt

>echo $MYDIR /usr/local/share/doc/foo

  • substitution by the result of the command inside the back quotes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

$( )

A

>MYDIR=$(dirname /usr/local/share/doc/foo/foo.txt)

>echo $MYDIR /usr/local/share/doc/foo

  • Substitution by the result of the command inside the parenthesis behind the $ sign
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Substitute the result of piped commands

A

>MYFILES=$(ls /etc | grep pa)

>echo $MYFILES

pam. d passwd
* Note we’re listing the contents of the /etc directory whose name starts with the string “pa”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly