With this command you will see the calendar with first day monday.

echo date "+%d %B %Y" | cal | awk '{ getline; print " Mo Di Mi Do Fr Sa So"; getline; if (substr($0,1,2) == " 1") print " 1 "; do { prevline=$0; if (getline == 0) exit; print " " substr(prevline,4,17) " " substr($0,1,2) " "; } while (1) }' | awk -v cday=date "+%d" '{ fill=(int(cday)>9?"":" "); a=$0; sub(" "fill int(cday)" ","("fill int(cday)")",a); print a }'

Update: I have changed the command to:

cal | awk '{ getline; print " Mo Di Mi Do Fr Sa So"; getline; if (substr($0,1,2) == " 1") print " 1 "; do { prevline=$0; if (getline == 0) exit; print " " substr(prevline,4,17) " " substr($0,1,2) " "; } while (1) }' | awk -v cday=date "+%d" '{ fill=(int(cday)>9?"":" "); a=$0; sub(" "fill int(cday)" ","("fill int(cday)")",a); print a }'

Leave a comment

Your email address will not be published. Required fields are marked *