This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:bkenne11:portfolio:pipe [2011/12/15 16:30] – [References] bkenne11 | user:bkenne11:portfolio:pipe [2011/12/15 17:40] (current) – [Attributes] bkenne11 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | A project for Systems Programming by Brandon Kennedy during the Fall 2011 Semester. | ||
+ | |||
+ | This project was begun on 12-15-2011 and is anticipated to take 1 day. | ||
+ | =====Objectives===== | ||
+ | By undertaking this project i hope to refresh on some scripting that I learned in unix/linux fundamentals. | ||
+ | =====Prerequisites===== | ||
+ | In order to successfully accomplish/ | ||
+ | |||
+ | * knowledge of Bash commands | ||
+ | * Matt Haas | ||
+ | * bash command list(google) | ||
+ | =====Background===== | ||
+ | I am hoping to regain some lost knowledge of shell scripting from unix/linux fundamentals. I will be using pipes, file I/0, I/0 redirection and some other things to brush up on the basics of shell scripting. | ||
+ | =====Scope===== | ||
+ | This script will receive a pathname from the user and will calculate how many files are in certain ranges like [a-g]. It will then output the directory path and the records of how many files are in each range to a file called rawdata. only errors should be printed to the screen. | ||
+ | =====Attributes===== | ||
+ | State and justify the attributes you'd like to receive upon successful approval and completion of this project. | ||
+ | |||
+ | * attribute1: File I/0 -> this script will output to a file | ||
+ | * attribute2: I/0 Redirection -> this script redirects its output to a file | ||
+ | * attribute3: directories -> this script changes to a directory and counts it's contents | ||
+ | * attribute4: Pipes -> This program uses pipes to send data from ls to wc to list and count directory entries. | ||
+ | * attribute5: file attributes -> this script creates and changes the permissions on a file called rawdata. | ||
+ | =====Code===== | ||
+ | |||
+ | <code c 1> | ||
+ | #hist.sh, a scripting program for systems programming and unix/linux fundamentals, | ||
+ | #program accepts a directory pathname and outputs to the file " | ||
+ | touch rawdata | ||
+ | chmod 660 rawdata | ||
+ | echo -n " | ||
+ | read directory | ||
+ | echo "" | ||
+ | |||
+ | echo " | ||
+ | cd $directory | ||
+ | echo "" | ||
+ | |||
+ | echo -n "Total Files: " >> rawdata | ||
+ | echo $(ls | wc -w) >> rawdata | ||
+ | echo "" | ||
+ | |||
+ | echo -n " | ||
+ | ls -d [a-gA-G]* | wc -w >> rawdata | ||
+ | echo "" | ||
+ | |||
+ | echo -n " | ||
+ | ls -d [h-mH-M]* | wc -w >> rawdata | ||
+ | echo "" | ||
+ | |||
+ | echo -n " | ||
+ | ls -d [n-sN-S]* | wc -w >> rawdata | ||
+ | echo "" | ||
+ | |||
+ | echo -n " | ||
+ | ls -d [t-zT-Z]* | wc -w >> rawdata | ||
+ | echo "" | ||
+ | echo "" | ||
+ | </ | ||
+ | |||
+ | =====Reflection===== | ||
+ | Shell scripting is an extremely powerful tool, and I hope i can dig into it more in the comming semesters. I deffinitely have a lot to learn, as I struggled getting even some basic tools to work. One of the harder things was 'ls -d [a-g]* | wc -w' I at first couldent get ls to only look at the directoy name, instead of traversing it, till i found the -d tag. | ||
+ | =====References===== | ||
+ | In performing this project, the following resources were referenced: | ||
+ | |||
+ | * manual page for ls | ||
+ | * manual page for wc | ||
+ | * I/0 redirection symbols via google |