User Tools

Site Tools


user:bkenne11:portfolio:pipe

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
user:bkenne11:portfolio:pipe [2011/12/15 16:03] – [Attributes] bkenne11user:bkenne11:portfolio:pipe [2011/12/15 17:40] (current) – [Attributes] bkenne11
Line 1: Line 1:
 +======Project: Pipes n' dirs======
  
 +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/perform this project, the listed resources/experiences need to be consulted/achieved:
 +
 +  * 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, by Brandon Kennedy
 +#program accepts a directory pathname and outputs to the file "rawdata"
 +touch rawdata
 +chmod 660 rawdata
 +echo -n "Please enter the the path to a directory:  "
 +read directory
 +echo ""
 +
 +echo "Directory: $directory" > rawdata
 +cd $directory
 +echo "" >> rawdata
 +
 +echo -n "Total Files: " >> rawdata
 +echo $(ls | wc -w) >> rawdata
 +echo "" >> rawdata
 +
 +echo -n "(a-g): " >> rawdata
 +ls -d [a-gA-G]* | wc -w >> rawdata
 +echo "" >> rawdata
 +
 +echo -n "(h-m): " >> rawdata
 +ls -d [h-mH-M]* | wc -w >> rawdata
 +echo "" >> rawdata
 +
 +echo -n "(n-s): " >> rawdata
 +ls -d [n-sN-S]* | wc -w >> rawdata
 +echo "" >> rawdata
 +
 +echo -n "(t-z): " >> rawdata
 +ls -d [t-zT-Z]* | wc -w >> rawdata
 +echo "" >> rawdata
 +echo "" >> rawdata
 +</code>
 +
 +=====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