On Fri 28 Feb 2014 15:54:56 NZDT +1300, Jim Cheetham wrote:
echo " M T W T F" for i in $(seq 2015 2115) do echo $i Jan $(cal 1 $i |sed -nr 's/^[[:digit:]]+ (([[:digit:]]+ ){5}).*/\1/;t h;b e;:h h;:e $x;$p') done
Oops:
echo " M T W T F" M T W T F for i in $(seq 2015 2018) do echo $i Jan $(/usr/bin/cal 1 $i |sed -nr 's/^[[:digit:]]+ (([[:digit:]]+){5}).*/\1/;t h;b e;:h h;:e $x;$p') done 2015 Jan 2016 Jan 2017 Jan 2018 Jan
Maybe you should have spent 3 days on sed, not 2...? ;-) The previously posted awk solution didn't work either because 15 years ago I had replaced cal with a cal that was doing a few useful things too, but with the linux-utils one it worked. Volker -- Volker Kuhlmann is list0570 with the domain in header. http://volker.top.geek.nz/ Please do not CC list postings to me.