Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
bashの日付から「日数」を引きたい。私はこのようなことを試みています..
echo $dataset_date #output is 2013-08-07 echo $date_diff #output is 2 p_dataset_date=`$dataset_date --date="-$date_diff days" +%Y-%m-%d` # Getting Error
これが私の解決策です:
echo $[$[$(date +%s)-$(date -d "2015-03-03 00:00:00" +%s)]/60/60/24]
現在から2015-03-03 00:00:00までの日数を計算します
以下のコードは、日付を1日短くします
ONE=1 dataset_date=`date` TODAY=`date -d "$dataset_date - $ONE days" +%d-%b-%G` echo $TODAY