awk -F "," '{if (gsub(/T/, ":"))print}' list.txt > list1.txt awk -F "," '{if (gsub(/-/, ":"))print}' list1.txt > list2.txt #list.txtの日時の切れ目の記号>を:に統一 read time1 #調べたい日時をtime1として入力 n=1 m=1 time2=`head -n 1 list2.txt | tail -n 1 | cut -c 8-26` #カバー範囲の先頭をtime2と定義 while [[ "${time2//':'}" < "${time1//':'}" ]]; do n=$(($n + 1)) time2=`head -n $n list2.txt | tail -n 1 | cut -c 8-26` done #time1をカバー範囲の先頭が初めて超えるファイルの検索(*) a=$(($n - 1)) file=`head -n $a list2.txt | tail -n 1 | cut -c 1-5` #その一つ前のファイルがお目当ての画像が あるファイルなのでそのファイル名をfileと定義 ls $file> shashinn.txt #そのファイルをテキストファイルに変換 time3=`head -n 1 shashinn.txt |tail -n 1 | cut -c 5-19` while [[ "${time3//'_'}" < "${time1//':'}" ]]; do m=$(($m + 1)) time3=`head -n $m shashinn.txt |tail -n 1 | cut -c 5-19` done #(*)と同様にtime1を初めて超える画像の検索 b=$(($m - 1)) time4=`head -n $b shashinn.txt |tail -n 1 | cut -c 5-19` echo $time4 #指定した日時の直前の画像の日時 echo $time3 #指定した日時の直後の画像の日時 cd $file eog *${time3}* & eog *${time4}* #指定した日時の前後の画像の表示 cd .. rm shashinn.txt rm list1.txt rm list2.txt #一時ファイルの削除