Due: Wednesday, April 17, 2018, at 11:59pm
In this assignment you'll gain some more experience with shell commands and with writing short shell scripts.
General hint: Before trying to write and debug a script, it's very helpful to first work out the necessary commands by experimenting in a shell window. Similarly, you can test one statement in your script at a time in your shell. Also, look at man pages and other descriptions of commands. Sometimes options are available that allow a single command to do something you want instead of having to use several commands or writing loops or complex control structures in a script.
Note: In each of the files you submit for HW2 you should include, at the top of the file, a comment that contains your name, HW2, Problem #, and the date.
GoHuskies
(and nothing more) is printed on
standard out, and nothing is printed on standard error when the
command is entered. You can precede your commands with other
commands (e.g., to create a file, run other commands, etc.) and/or
pass options or arguments to your commands. Solve this problem for
each of the listed commands individually.echo, cat, ls, grep, !!In a text file called
problem1
describe your
solutions, including each command you use and a very brief
explanation of it, including information about any additional commands
or operations that were done before executing that command.
And, yes, "nothing more" in
the output means "nothing
more".private
such that
when you run private foo
, the entire subtree of the
file-system starting at foo
(so just foo
if it is a file, but foo
and all of its files and
subdirectories recursively if it is a directory) has its
permissions changed as follows:
defprivate
such that
entering source defprivate
would
make private
available in the current shell
(i.e., source defprivate
makes the private
command available for use in the current shell,
but does not actually execute it immediately). The alias should also
work on multiple arguments.g=u
.combine
that takes 2
or more arguments, call them f1, f2, ...,
fn
. Script combine
should work as follows:stderr
and exit
with a return code of 1.f1
already exists, print
"Error: first file exists" on stderr
and
exit with a return code of 1.f2, ...,
fn
and copy them to stdout
. Do not print
any error messages from this (for example if some file does
not exist or is a directory). Instead, any such error messages
should be written to f1
. Exit
with a return code of 0 after copying the files to stdout
.
/dev/stdout
or /dev/stderr
. These are not portable across *nix
systems. Although they are found on most versions of Linux the
problem can be solved without them.shift, $@, -lt, -a
.currentlinecount
that works as follows:total
../datedlinecount log foo bar;
./datedlinecount log foo*; cat log
might produce
something like:Wed Apr 3 09:22:16 PDT 2019 18 foo 23 bar 41 total Wed Apr 3 09:22:17 PDT 2019 18 foo 6 foot 24 totalHints:
shift, date, wc, $@
.bash
on either of our
reference systems (klaatu
or the current CSE Linux virtual
machine).Turn-in Instructions: Please submit your files to the
Canvas HW2 Assignment. You can combine your files into an archive (see the tar
command) and turn that in as a single file. The choice is yours; do
whichever is most convenient.
The drop box will allow you to turn in your homework up to two days late, if you choose to use one or two of your late days, but you are strongly advised to save your late days for later in the quarter when they are almost certain to be much more useful.