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:
2
  • 1
    Would cal -w -y be enough? From that you can grep and awk what you need. Commented Jun 16, 2016 at 2:29
  • what i meant is i wanted to generate the file looks as above. Commented Jun 16, 2016 at 7:36

1 Answer 1

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.