フォルダー内の一連の pcap ファイルを圧縮するための Linux スクリプトを作成しました。2 日以上前のファイルを zip ファイルに保存します。zip は、zip のファイル名として現在の日時で保存されます。最初と最後の pcap ファイルを zip ファイルのファイル名として使用する方法はありますか。
#!/bin/bash
cd /mnt/md0/capture/DCN
#Limit of your choice
ulimit -s 32000
LIMIT=10
#Get the number of files, that has `*.pcap`
in its name, with last modified time 5 days ago
NUMBER=$(find /mnt/md0/capture/dcn/ -maxdepth 1 -name "*.pcap" -mtime +5 | wc -l)
if [[ $NUMBER -gt $LIMIT ]] #if number greater than limit
then
FILES=$(find /mnt/md0/capture/dcn/ -maxdepth 1 -name "*.pcap" -mtime +5)
#find the files
zip -j /mnt/md0/capture/dcn/capture_zip-$(date "+%b_%d_%Y_%H_%M_%S").zip $FILES
#zip them
rm $FILES
#delete the originals
ulimit -s 8192 #reset the limit
fi #end of if.