Last year I had created a shell script which showed me my academic timetable for the day. I was a newbie in shell scripting at that time and hence the script was not so good. Hence, here is tt or I should say timetable2.0 ?
This time I have stored my timetable in a timetable.txt file so that whenever I need to modify the timetable, I don't need to modify the script. Also, the code is much shorter this time with not so many if statements. Here is the new code:
#!/bin/bash
days=( Monday Tuesday Wednesday Thursday Friday )
if [ "$#" == 0 ]
then
echo -e "\nToday's Timetable:"
set `date +%u`
else
echo -e "\n"${days[$1-1]}"'s timetable:"
fi
sed -n $1p < timetable.txt
echo -e "\n\n"
Still to be added: Feature to change the timetable. But that's all for now. The new modification will come when I feel the mood of it :)
Tweet
This time I have stored my timetable in a timetable.txt file so that whenever I need to modify the timetable, I don't need to modify the script. Also, the code is much shorter this time with not so many if statements. Here is the new code:
#!/bin/bash
days=( Monday Tuesday Wednesday Thursday Friday )
if [ "$#" == 0 ]
then
echo -e "\nToday's Timetable:"
set `date +%u`
else
echo -e "\n"${days[$1-1]}"'s timetable:"
fi
sed -n $1p < timetable.txt
echo -e "\n\n"
Still to be added: Feature to change the timetable. But that's all for now. The new modification will come when I feel the mood of it :)
Tweet