You may work in pairs, if space demands.                 
The purpose of this assignment is to get you started writing Linux
scripts using bash
. You will create and edit a bash script in class
that uses many of the features of shell scripts described in the
lecture.
                
Make sure you can login to the Linux system using the ct320 user and the password given to you be 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 find
and grep
, as shown by
the following sequence:
$ cd /bin $ find . -print | grep dir $ find . -print | grep ch
Practice arranging output in order by name or size or date using ls
and 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
ends.
                
Practice splitting an output stream to the terminal and a file using
echo
and 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 ls
and
chmod
, in conjunction with xargs
, as shown by the following
sequence:
$ 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:
bscript
.
# Students: name1, name2 # Logins: login1, login2 # Assignment: CT320 BashI # Date: YYYY-MM-DD
directory
.
chmod a=rwx
for all contents.
/tmp/archive
.
In addition to the previous requirements, the script must do the following:                 
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:                 
When you have tested your script, and it works, show your work to the TA.                 
Modified: 2015-10-17T23:01                  User: Guest                  Check: HTML CSSEdit History Source |
Apply to CSU |
Contact CSU |
Disclaimer |
Equal Opportunity Colorado State University, Fort Collins, CO 80523 USA © 2015 Colorado State University |