是否可以在Unix中获取每月的第5天和/或第6天?
我试过这个,但它没有给我想要的输出:
echo $((($(date +%-d)-1)/5))
dr01.. 5
用这个:
for month in {1..12}; do date -d "$month/5/2017" +"%c - is a %A"; done
输出:
Thu 05 Jan 2017 12:00:00 AM CET - is a Thursday Sun 05 Feb 2017 12:00:00 AM CET - is a Sunday Sun 05 Mar 2017 12:00:00 AM CET - is a Sunday Wed 05 Apr 2017 12:00:00 AM CEST - is a Wednesday Fri 05 May 2017 12:00:00 AM CEST - is a Friday Mon 05 Jun 2017 12:00:00 AM CEST - is a Monday Wed 05 Jul 2017 12:00:00 AM CEST - is a Wednesday Sat 05 Aug 2017 12:00:00 AM CEST - is a Saturday Tue 05 Sep 2017 12:00:00 AM CEST - is a Tuesday Thu 05 Oct 2017 12:00:00 AM CEST - is a Thursday Sun 05 Nov 2017 12:00:00 AM CET - is a Sunday Tue 05 Dec 2017 12:00:00 AM CET - is a Tuesday
在本月6日,它以类似的方式完成.
用这个:
for month in {1..12}; do date -d "$month/5/2017" +"%c - is a %A"; done
输出:
Thu 05 Jan 2017 12:00:00 AM CET - is a Thursday Sun 05 Feb 2017 12:00:00 AM CET - is a Sunday Sun 05 Mar 2017 12:00:00 AM CET - is a Sunday Wed 05 Apr 2017 12:00:00 AM CEST - is a Wednesday Fri 05 May 2017 12:00:00 AM CEST - is a Friday Mon 05 Jun 2017 12:00:00 AM CEST - is a Monday Wed 05 Jul 2017 12:00:00 AM CEST - is a Wednesday Sat 05 Aug 2017 12:00:00 AM CEST - is a Saturday Tue 05 Sep 2017 12:00:00 AM CEST - is a Tuesday Thu 05 Oct 2017 12:00:00 AM CEST - is a Thursday Sun 05 Nov 2017 12:00:00 AM CET - is a Sunday Tue 05 Dec 2017 12:00:00 AM CET - is a Tuesday
在本月6日,它以类似的方式完成.