Answer the question below:
a. Read the caution titled “Always quote positional parameters” on page 475
of Sobell. Use touch to create a file whose name has a SPACE in it. What hap-
pens when you give that filename as an argument to cptobak from the
previous step?
b. Modify the cptobak script from the previous step by quoting the positional
parameters in the cp line. Now what happens when you use the script to
make a copy of a file with a SPACE in its name?
a.
$ touch aa\ bb
$ ls -l aa*
-rw-rw-r-- 1 mark mark 0 Jan 15 16:35 aa bb
$ ./cptobak aa*
cp: target `bb.bak' is not a directory
The shell passes one argument (that includes a SPACE) to cptobak: aa bb. But
when the shell that is running cptobak parses $1, it expands it to two argu-
ments because it contains an unquoted SPACE; the shell passes to cp four
arguments:
cp aa bb aa bb.bak
When you pass more than two arguments to cp, the last argument must be
a directory: cp copies the files named by the first arguments into the direc-
tory named by the last argument. If the last argument is not a directory, cp
displays an error message.
b.
$ cat cptobak
...
cp "$1" "$1.bak"
$ ./cptobak aa*
$ ls aa*
aa bb aa bb.bak
You might also like to view...
The ____________ declares that a derived class is allowed to override the current method in the base class.
a. override keyword b. class keyword c. virtual keyword d. static keyword
Digital data is _____ and analog information is _____.
A. continuous; discrete B. discrete; continuous
A __________ takes place when one entity pretends to be a different entity.
A) replay B) masquerade C) service denial D) passive attack
The process of deploying fee-based software over the Internet is termed _____.
A. Applications as a Service B. Programs as a Service C. Software as a Service D. Software Service