#!/bin/bash
echo "Author: Joe"
echo "Date: Saturday, May 02, 2009"
echo
echo "Displaying the content of a file from week 2."
echo
cat /mnt/sdb/week2/joe.3-7
echo
echo
echo "Please enter week number (1, 2 or 3) or q to quit."
read num
echo
((test=1))
while test $num != q
do
if [ $num -lt 4 ]
then
echo "The files submitted in week $num are:"
ls ../week$num/joe*
else
echo "Incorrect week number!"
fi
((file=1))
while test $file != q
do
echo
echo "Please enter file name to view the contents."
read file
if [ -f ../week$num/$file ]
then
echo
echo "The contents of file $file are:"
cat ../week$num/$file
echo "The files submitted in week $num are:"
ls ../week$num/joe*
else
read -p "Incorrect file name! Please select again or enter q"
fi
((file++))
done
((test++))
echo
echo "Please enter week number (1, 2 or 3) or q to quit."
read num
echo
done
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
However as I look over your answer that would work too.
I dont know how I should score it?