たつをの ChangeLog : 2021-03-03

自分用のプログラミングメモ。

### ファイルが存在&最終更新日時がXX秒以内=>なにもしない
if [ -e $fn ] && [ $((`date +%s` - $(stat -f %Sm -t %s $fn))) -le 7200 ]; then
    echo DoNothing $fn
    continue
fi
# 何かする(更新処理など)
echo DoSomething $fn
# 例: $dir/create_or_update_file.sh $fn


### ファイルが存在&最終更新日が今日=>なにもしない
if [ -e $fn ] && [ `date +%Y%m%d` -eq `stat -f %Sm -t %Y%m%d $fn` ]; then
    echo DoNothing $fn
    continue
fi
# 何かする(更新処理など)
echo DoSomething $fn
# 例: $dir/create_or_update_file.sh $fn


# [memo] st_mtime にファイルの最終更新時をセットする方法2つ
# 1.  eval $(stat -s $fn)
# 2.  st_mtime=$(stat -f %Sm -t %s $fn)

# [memo] 現在時刻 (Unixtime) の取得
# ut=$(date +%s)
# ut=`date +%s`

たつをの ChangeLog
Powered by chalow