How do I use sed
to substitute date by a word. I tried doing this:
tmp=`date +%d`
echo $tmp
if [ $tmp -lt 10 ]
then
pat="d"
echo $pat
else
pat="dd"
echo $pat
fi
cal | sed "s/$tmp/$pat/"
And the output is like so:
robin@robin-VirtualBox:~/lx$ bash p13.sh
27
dd
April 2014
Su Mo Tu We Th Fr Sa
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
Edit:
I want the date 27
to change into dd
, like in here:
April 2014
Su Mo Tu We Th Fr Sa
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
dd 28 29 30
27
specifically, weird. I'm assuming there is some issue with the current day.