Hatena::ブログ(Diary)

揮発性のメモ このページをアンテナに追加 Twitter

2014/09/30 (火)

findで日付指定

findで日付指定して検索する際、 ▲日前ではなく、★月▼日を指定したい


2014-09-25 00:00:00 から 2014-09-25 23:59:59 までのファイル検索


★月▼日が何日前かを計算して指定する

STARTTIME=$(( (`date +%s`-`date --date='2014-09-25' +%s`)/86400 +1 ))
ENDTIME=$(( (`date +%s`-`date --date='2014-09-26' +%s`)/86400 -1 ))

find ./ -daystart -mtime -$STARTTIME -and -mtime +$ENDTIME

newermtオプションを使用する

findコマンドで日付指定を使っての期間絞込み - cakephperの日記(CakePHP, Laravel, PHP)

find ./ -newermt '2014-09-25' -and ! -newermt '2014-09-26'

ファイルを二つ指定する

touch start.txt -m -d "2014-09-24 23:59:59.9999"
touch end.txt -m -d "2014-09-25 23:59:59.9999"

find ./ -newer start.txt -and ! -newer end.txt

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証

トラックバック - http://d.hatena.ne.jp/iww/20140930/find
リンク元
2006 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2007 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2008 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2009 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2010 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2011 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2012 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2013 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2014 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2015 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |