Corning Community College
UNIX/Linux Fundamentals
Case Study 0xD: Analyzing Shell Script Logic
~~TOC~~
To gain additional familiarity with shell scripting.
Shell scripting enables you countless possibilities for automating tasks, both menial and sophisticated in nature.
However, like any new tool or concept, one needs to spend time with, and play with things, to get a better understanding.
Analyze, poke at, and get running the following script on Lab46:
#!/bin/bash month="`date +%m`" year="`date +%Y`" day="`date +%d`" today="${year}${month}${day}" csem="" for item in `wget -q -O - http://www.corning-cc.edu/future/acacalendar/ \ | grep 'Semester begins' | sed 's/\.\.*/:/g' \ | sed 's/<[/a-z0-9]*>//g' | sed 's/:Semester begins : /:/g' \ | sed 's/:First Summer Session begins : /:/g' \ | egrep -o '[FWS][a-z]* [0-9]{4} S[a-z]*:[A-Z][a-z]* [1-9][0-9]?' \ | tr 'WSF' 'wsf' | sed 's/ \([1-9][0-9][0-9][0-9]\) semester/\1/g' \ | sed 's/ /*/g'`; do sm="`echo $item | cut -d':' -f1`" out=$(date --date "`echo $item \ | sed 's/^[a-z]*\([0-9]*\):\([A-Za-z]*\)\*\([0-9]*\)$/\2 \3 \1/'`" \ +%Y%m%d) if [ "$today" -ge "$out" ]; then csem="$sm" fi done echo "$csem" if [ -z "$csem" ]; then status=1 else status=0 fi exit $status
All questions in this assignment require an action or response. Please organize your responses into an easily readable format and submit the final results to your instructor.
Your assignment is expected to be performed and submitted in a clear and organized fashion- messy or unorganized assignments may have points deducted. Be sure to adhere to the submission policy.
The successful results of the following actions will be considered for evaluation:
<html><center><a href=“http://lab46.corning-cc.edu/haas/content/unix/submit.php?csd”>http://lab46.corning-cc.edu/haas/content/unix/submit.php?csd</a></center></html>
As always, the class mailing list and class IRC channel are available for assistance, but not answers.