how to generate a text file in Linux as below.

Workweek, with 7 dates on each line.

  • 1
    Would cal -w -y be enough? From that you can grep and awk what you need. – grochmal Jun 16 '16 at 2:29
  • what i meant is i wanted to generate the file looks as above. – user548682 Jun 16 '16 at 7:36

Something like this, perhaps:

for i in {0..202} ; do date --date "$i days 2016-05-21" +%Y%m%d ; done |\
   awk 'NR%7==1 {print ""} {printf $1 ":"}' | \
   awk 'BEGIN { n=22 } $1!="" { printf "2016WW%02d=%s\n",n++,$1}'

Adjust numbers to your likings.

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.