Linux 如何在shell中获得一年中的一天?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10112453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:44:17 来源:igfitidea点击:
how to get day of the year in shell?
提问by Reza Toghraee
How can I get the day of the yearin shell?
我怎样才能在shell中获得一年中的一天?
date '+%V'
will give me the week of the year, which is 15 for today; but I need to find the day of the year!
date '+%V'
会给我一年中的一周,今天是 15;但我需要找到一年中的哪一天!
采纳答案by Mat
回答by Peter.O
Use the date
command and the %j
option...
使用date
命令和%j
选项...
doy=$(date +%j)