3

how'd I get a listing of the months in the year (abbreviated) using dseq from dateutils?

NOTE
simply running:

dseq 'jan' 'dec' -i '%b' -f '%b'

returns a humongous list of months:

piping the output to uniq reveals an out of order list of months:

Dec
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov

Any ideas on how to correct the order of the list of months using sed or just by passing a certain parameter to dseq?

1
  • 1
    I know this isn't an answer, but: seq 20130101 100 20131201 | date +%b -f- worked just fine for me.
    – rici
    Nov 25, 2013 at 20:24

3 Answers 3

2

Setting the increment to 1 month (1mo) only steps through the actual month names, the command would then be:

dseq 'jan' 1mo 'dec' -i '%b' -f '%b'

returns:

Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
1

This sorts by date and uses sort to make it unique:

dseq 'jan' 'dec' -i '%b' -f '%b' | sort -Mu
0

I managed to fix the output using the following:

dseq 'jan' 'dec' -i '%b' -f '%b' | uniq | sed -r '/(Nov|Dec)/d; /Oct/aNov\nDec'
4
  • @richard lemme see the output please. Post a pastebin or something. Nov 26, 2013 at 17:13
  • I just noticed that, my previous comment is wrong. The input I used to test was wrong, taken from link in question, it has output of dseq twice. Nov 27, 2013 at 15:06
  • @richard, okay, so what are you trying to say? What do you get when you run dseq 'jan' 'dec' -i '%b' -f '%b'? Nov 27, 2013 at 16:29
  • I am saying to disregard the comment, that said that the answer is wrong. ( I deleted it now ). Nov 28, 2013 at 10:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .