This is my Unix Assignment where I need to write a script which shows today's date in calender and here's my code and the output. My professor gave me grade with feedback saying "fix the command there is a bug in it". I can't seem to figure out the bug. Any help will be great!
command is $c5/n*/4*/s*/today
Where those are just some directories and today is the name of my file. When I type in that command I see what I want to see which is output of my script, then how can there be a bug in my command.
#!/usr/dt/bin/dtksh
date
if [ $# -ge 1 ] ; then
exec $HOME/bin/cal $*
fi
#highlight today on this months calendar
daynumber=`date +%d`
#tput gets terminal specific characters, e.g. clear
rmso=`tput rmso` # get the chars for reverse video for this
smso=`tput smso` # terminal using tput
if [ $daynumber -lt 10 ] ; then
daynumber=" `echo $daynumber | sed 's/^0//`"
# daynumber=" `echo $daynumber | cut -c 2`"
fi
if cal | grep "$daynumber\$" > /dev/null; then
cal | sed "2,$ s/$daynumber/$smso$daynumber$rmso /"
else
cal | sed "2,$ s/$daynumber /$smso$daynumber$rmso /"
fi
Output... 30 will be highlighted since that is today's date.
Sun Mar 30 14:22:31 CDT 2014
March 2014
S M Tu W Th F S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
**30** 31
$*
and"$@"
are very different things, and you almost certainly want the latter. – Charles Duffy Mar 30 at 19:38daynumber=${daynumber%0}
is much, much faster than forking, starting a pipeline, waiting for it to exit, etc. – Charles Duffy Mar 30 at 19:40daynumber=...sed...
line. – Jonathan Leffler Mar 30 at 19:40