From f8e6e1888a1cbd27470f4ddb2bb8a5ff6c361315 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Thu, 29 Sep 2011 12:15:07 +0200 Subject: contrib: Use explicit globs and regexps --- contrib/osmo_pcap_clean_old | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/osmo_pcap_clean_old b/contrib/osmo_pcap_clean_old index 640441e..0f4fc6c 100755 --- a/contrib/osmo_pcap_clean_old +++ b/contrib/osmo_pcap_clean_old @@ -30,7 +30,7 @@ cd "$BASEPATH" do_cleanup_age() { - find . -ctime +$MAXAGE -name "trace-$1*" |sort -r | while read LOG; do + find . -ctime +$MAXAGE -name "trace-$1-*.pcap*" |sort -r | while read LOG; do [ $VERBOSE -eq 1 ] && echo "Deleting file \"$LOG\"" rm -f "$LOG" done @@ -39,7 +39,7 @@ do_cleanup_age() do_cleanup_files() { i=1 - find . -name "trace-$1*" |sort -r | while read LOG; do + find . -name "trace-$1-*.pcap*" |sort -r | while read LOG; do if [ $i -gt $MAXFILES ]; then [ $VERBOSE -eq 1 ] && echo "Deleting file \"$LOG\"" rm -f "$LOG" @@ -51,7 +51,7 @@ do_cleanup_files() do_zip() { i=1 - find . -name "trace-$1*" |sort -r | while read LOG; do + find . -name "trace-$1-*.pcap*" |sort -r | while read LOG; do if [ $i -gt $ZIPAFTER ]; then if [ "${LOG##*.}" != "gz" ]; then [ $VERBOSE -eq 1 ] && echo "Compressing file \"$LOG\"" @@ -62,7 +62,9 @@ do_zip() done } -find . -name "trace-*" |sed -e "s/.*trace-\(.*\)-\(.*\).pcap.*/\1/" |sort |uniq | while read CLIENT; do +# Use an explicit pattern here +find . -name "trace-*.pcap*" |sed -n -e "s/.*trace-\(.\+\)-[0-9]\{8\}_[0-9]\{6\}\.pcap\(\..\+\)\?/\1/p" |sort |uniq | while read CLIENT; do + [ $VERBOSE -eq 1 ] && echo "Cleaning logs for $CLIENT" if [ "x$METHOD" == "xAGE" ]; then -- cgit v1.2.3