I need to write few line in a code that I use in my study, and I really gave up! currently, i can list the days of a month and the equivalent day number but I can't link this to the system clock so it pulls out the correct number of the date in each month and automatically every month.
here is what I did:
#!/bin/bash
for (( i = 0; i < 30; ++i )); do
echo -e "$( date -d "now +${i} days" +"%a" )", ${i}
done
output:
Fri, 0
Sat, 1
Sun, 2
Mon, 3
Tue, 4
Wed, 5
Thu, 6
Fri, 7
Sat, 8
Sun, 9
Mon, 10
Tue, 11
Wed, 12
Thu, 13
. . . .
.. . etc
I would like this code to list the correct number of the days in a given month. For example, in October there are /31/ days. When I run the code in November it must list 30 days, and when I run it in March it lists 31 days and in February it lists 28 or 29 days, and so on. How can I do that?