# 這裏的例子天天做爲循環,並展現當天的前一天 #!/bin/bash startDate=20160201 endDate=20160328 startSec=`date -d "$startDate" "+%s"` endSec=`date -d "$endDate" "+%s"` for((i=$startSec;i<=$endSec;i+=86400)) do current_day=`date -d "@$i" "+%Y%m%d"` one_day_ago=`date -d "$current_day yesterday" +%Y%m%d` echo "current_day:${current_day}, yesterday:${one_day_ago}" done
中止指定程序bash
$ps -ef | grep firefox | grep -v grep | cut -c 9-15 | xargs kill -s 9 firefox