The purpose of this assignment is to get you started writing Linux scripts using the bash shell. 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 Gnome desktop well enough to run the Firefox browser, file manager, and gedit and terminal programs.
Practice redirection and pipes using the find and grep commands, 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 the ls and sort commands, as shown by the following sequence:
$ ls -l | sort -k 9 $ ls -l | sort -k 5 -n
Practice splitting an output stream to the terminal and a file using the echo and tee commands, as shown by the following sequence:
$ cd ~ $ echo “This string should be displayed and written to the file” | tee string.txt $ cat string.txt
Practice splitting an output stream to the terminal and a file using the echo and tee commands, as shown by the following sequence:
$ cd ~ $ echo “This string should be displayed and written to the file” | tee string.txt
Practice operating on all of the files in a directory using the 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 666 $ ls -l
Write a script that does all of the following:
# Students: name, name, ... # Ids: 8xx-xx-xxxx, 8xx-xx-xxxx, ... # Course: CT320 # Assignment: Recitation R1 # Date: YYYY-MM-DD
In addition to the previous requirements, the script must do the following:
NOTE: 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:
You will now be shown how to turn your script file into the Recitation 1 drop box on RamCT. The lab is done in teams of two, but each student must submit to get credit.
Modified: 2013-09-04T11:10 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 |