1

how to generate a text file in Linux as below.

Workweek, with 7 dates on each line.

2016WW22=20160521:20160522:20160523:20160524:20160525:20160526:20160527:
2016WW23=20160528:20160529:20160530:20160531:20160601:20160602:20160603:
  • 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
1

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.