How can I format the output of the command cal -y 2020 as a csv? I want to prepare the calendar in a table processor. Can this be done?

I am using Slackware 14.2.

  • 3
    What output? Just one month? cal -3? Maybe cal -Y? Which cal? Are you on Linux? MacOS? BSD? Something else? Please edit your question and clarify. – terdon Sep 12 at 8:56
  • Slackware is a Linux distribution. – Soruk Sep 12 at 9:09
  • @Soruk yes, thank you, I am aware of that :) That was only added after I commented. – terdon Sep 12 at 10:31

Try this,

 cal 2020  | sed 's/ \([0-9]\) /\1 /g;s/ \([0-9]\)$/\1/g;s/ /,/g;s/,,,/,/g' > 2020.csv

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.