Complete this assignment by downloading this HTML file and editing it (using a text editor---not a special HTML editor). Wherever you see emphasized text (e.g. "Your name" and "Your Student Number" above) you should insert your own text, as appropriate. Submit via D2L by 2:15 p.m. on Monday, February 8.
Consider the following commands used to make a backup of a file:
$ # version 1
$ mkdir backup
$ cp foo backup/foo
$ # version 2
$ mkdir backup
$ ln foo backup/foo
Which version is more efficient, justify your answer. Are there any disadvantages?
*Change this with your answer
Assume x
is a file, and d
is a
directory, both in the current directory, describe what happens
to the directories .
(i.e., the current directory)
and d
when each of the following commands are
executed (the commands are independent). You should state what
entries are deleted, changed, or added to each directory.
$ mv x y
*Change this with your answer
$ mv x d
*Change this with your answer
$ mv x d/y
*Change this with your answer
In a terminal window, enter the following:
$ mkdir foo; cd foo
$ touch ab abc de.txt h1.class h3.class
What is output by the following commands:
$ echo h*
*Change this with your answer
$ echo *[bs]
*Change this with your answer
$ echo *cl*
*Change this with your answer
$ echo [ad]*
*Change this with your answer
Determine the type (using type
) of the following
commands. If the command is built in, can you suggest a
possible reason why? Usually this relates to information
contained within the shell itself.
cd
*Change this with your answer
type
*Change this with your answer
history
*Change this with your answer
ls
*Change this with your answer
man
*Change this with your answer
Using redirection give the command line that changes
echo hi there
to:
save the standard output to the file
fred
.
*Change this with your answer
append the standard output to fred
.
*Change this with your answer
write both standard output and error to
sue
*Change this with your answer
The same as the previous question using the alternate syntax
*Change this with your answer
write standard error to err
and discard the
standard output to /dev/null
.
*Change this with your answer
Using the shell expansion ability:
write one command that creates the directories:
cs2718/assign1
, cs2718/assign2
, and
cs2718/assignX
. Do not assume
cs2718
exists.
*Change this with your answer
write one command that creates the directories:
cs2718/assign1/data
,
cs2718/assign2/data
,
cs2718/assignX/data
. Do not assume any of the
directories exist.
*Change this with your answer
write one command that creates the empty files:
a0
, a1
, a2
,
a3
, a4
, a5
,
a6
, a7
, and a8
. You
must use brace expansion.
*Change this with your answer
How does bash
expand the following command line
arguments (assume you are using Ubuntu 14.04 in the lab):
$HOME
*Change this with your answer
"$HOME/afile"
*Change this with your answer
"$USER"
*Change this with your answer
$PATH
*Change this with your answer
A file called checkthis
is created with:
$ echo -e "ls\ncd\ndf\nhistory" > checkthis
Write one command line that uses command substitution to
determine the command type, with type
, for each
command on a separate line from the file
checkthis
. Show the command line's output.
*Change this with your answer
Write one command line that uses command substitution to
determine the location of the commands listed in
checkthis
. Show the command line's output.
Explain the output.
*Change this with your answer