You may work in pairs, if space demands.
The purpose of this assignment is to get you started writing Linux
bash. You will create and edit a bash script in class
that uses many of the features of shell scripts described in the
Make sure you can login to the Linux system using the ct320 user and the password given to you by the instructor or teaching assistant. Make sure that you understand the system well enough to run a browser, file manager, terminal and text editor.
Practice redirection and pipes using
grep, as shown by
the following sequence:
$ cd /bin $ find . -print | grep dir $ find . -print | grep ch
Advanced students may realize that these pipelines can be reduced
Practice arranging output in order by name or size or date using
sort commands, as shown by the following sequence:
$ ls -l | sort -k 9 $ ls -l | sort -k 5 -n
Of course, there are probably
ls options to accomplish the same
Practice splitting an output stream to the terminal and a file using
tee, as shown by the following sequence:
$ cd $ echo "Brush your teeth after every meal" | tee string.txt $ cat string.txt
Practice operating on all of the files in a directory using
chmod, in conjunction with
xargs, as shown by the following
$ mkdir temp $ cd temp $ echo "File 1" >file1.txt $ echo "File 2" >file2.txt $ echo "File 3" >file3.txt $ echo "File 4" >file4.txt $ ls -l $ ls | xargs chmod a=rw $ ls -l
Write a script that does all of the following:
# Students: name1, name2 # Logins: login1, login2 # Assignment: CT320 BashI # Date: YYYY-MM-DD
unprotect, sets protections using
chmod a=rwxfor all contents.
list, displays a long directory listing.
delete, deletes all files and dirs recursively.
archive, copies all files and directories to
In addition to the previous requirements, the script must:
/tmp/archiveif it does not exist.
bscript.log, creating it anew for each run.
You might want to make a backup copy of the
Test directory before
testing any commands in case your script intentionally or accidentally
deletes files. Now test your script as follows:
list, and examine the resulting listing.
archive, and check
deleteand make sure
When you have tested your script, and it works, show your work to the TA.