获取前一天的日期
Ubuntu
date +%Y%m%d --date='-1 day'
MAC
date -v -1d +%Y-%m-%d
获取后一天的日期
Ubuntu
date +%Y%m%d --date='1 day'
MAC
date -v +1d +%Y-%m-%d
根据OS平台获取前一天的日期
#!/bin/bash
# author Kang, Leo
# date 2016-5-26
pre_date=0
os_name=$(uname -s)
if [[ "$os_name" == "Linux" ]]; then
#statements
pre_date=$(date +%Y-%m-%d --date='-1 day')
elif [[ "$os_name" == "Darwin" ]]; then
pre_date=$(date -v -1d +%Y-%m-%d)
fi