Write a sequence of commands or a script that demonstrates variable expansion occurs before pathname expansion.
What will be an ideal response?
The following sequence of commands demonstrates variable expansion
occurs before pathname expansion:
$ ls g?
g1 g2 g5 g8
$ a=g?
$ echo "$a"
g?
$ echo $a
g1 g2 g5 g8
Because neither single nor double quotation marks allow pathname expansion,
the first echo command displays the unexpanded argument g?. The shell
expands the variable but does not expand the pathname.
If pathname expansion occurred prior to variable expansion, the shell, in
the case of the second echo, would not treat the question mark as a special
character. After expansion, the argument that the shell passed to echo would
be g?, which echo would display.
Following is another example that demonstrates variable expansion occurs
before pathname expansion:
$ cat t1
touch /tmp/$1*
$ touch /tmp/hello
$ ls -l /tmp/hello
-rw-rw-r--. 1 max pubs 0 03-24 19:55 /tmp/hello
$ sleep 60
$ t1 h
$ ls -l /tmp/hello
-rw-rw-r--. 1 max pubs 0 03-24 19:56 /tmp/hello
You might also like to view...
A __________ is a collection of similar records.
A) ?file ? B) ?database ? C) ?record D) ?field
When you use your computer to view webpages, you are browsing or surfing the web
Indicate whether the statement is true or false
Appear, Fly in, and Grow & Turn are examples of ________ effects
A) Motion B) Entrance C) Emphasis D) Exit
When performing a search, you can limit the search to a file property by separating the name of the property and the search term with a(n) ________
A) colon (:) B) hyphen (-) C) underscore (_) D) period (.)