2

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
    I know this isn't an answer, but: seq 20130101 100 20131201 | date +%b -f- worked just fine for me. – rici Nov 25 '13 at 20:24
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'
  • @richard lemme see the output please. Post a pastebin or something. – Alexej Magura Nov 26 '13 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. – ctrl-alt-delor Nov 27 '13 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'? – Alexej Magura Nov 27 '13 at 16:29
  • I am saying to disregard the comment, that said that the answer is wrong. ( I deleted it now ). – ctrl-alt-delor Nov 28 '13 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.