bash - 使用给定日期获取那一年中的哪一天
问题描述
例如,我给了 31-dec-2020 它应该返回 365th 我在下面的 bash 中尝试过,但它不起作用。
start_of_year= "2020-01-01"
echo "enter date in yyy-mm-dd format"
read current_date
difference= `expr $current_date - $start_of_year`
echo "day of the year $difference"
解决方案
date -d "$current_date" +%j
格式化程序返回一年中的%j
天数。见人日期。
推荐阅读
- r - 如何在 dplyr 分组数据上使用 rollmean
- c++ - 我的代码已成功提交,但尝试在代码厨师上运行代码时出现 SIGSEGV 错误
- css - 我尝试在 macOS 上的 CSS 中回退 SF Compact Rounded,而不是 -applye-system
- android - 如何发送 MutableList
在 kotlin 中从意图到另一个 - reactjs - Formik - FieldArray : 提供给的 `value` 道具
- node.js - Mongoose Aggregate:来自变量 $in 数组的 ObjectId 未返回 true
- python - 从python中的大(40GB)tar文件一次访问一个文件
- javascript - 防止嵌套表单的按钮提交整个表单
- python - /usr/bin/ld: 找不到 -lboost_python-py34
- python - TypeError:连接两个表时,“列”对象不可调用 Pysarpk