diff --git a/snapaid.sh b/snapaid.sh index ab9a905..b059292 100755 --- a/snapaid.sh +++ b/snapaid.sh @@ -313,6 +313,7 @@ if [ x"$1" = x"verify" ]; then verifyfile "$vermid" "$i" done elif [ x"$1" = x"find" ]; then + shift fetch "$currenturl" tmpdir=$(mktemp -d -t snapaid) @@ -320,11 +321,12 @@ elif [ x"$1" = x"find" ]; then trap "rm -r $tmpdir" 0 ( cd "$tmpdir"; - xzcat "$STOREDIR"/snapshot.idx.xz | sort -r -k 5 > selection; + xzcat "$STOREDIR"/snapshot.idx.xz | sort -r -k 5 -k 2 > selection; while :; do - # display current list cnt=$(wc -l < selection) - awk ' + if [ x"$1" = x"" ]; then + # display current list + awk ' BEGIN { # xzcat snapshot.complete.idx.xz | ./maxcol.awk # xzcat snapshot.complete.idx.xz | awk "{ print $3}" | sort -u @@ -347,9 +349,15 @@ BEGIN { cnt += 1 } - ' selection + ' selection + fi - read -p 'Select image #, enter search term, reset, or quit: ' sel + if [ x"$1" != x"" ]; then + sel="$1" + shift + else + read -p 'Select image #, enter search term, reset, or quit: ' sel + fi if [ x"$sel" = x"reset" ]; then xzcat "$STOREDIR"/snapshot.idx.xz | sort -r -k 5 > selection; continue @@ -491,7 +499,7 @@ else fi echo "Usage:" echo " $0 verify file ..." - echo " $0 find" + echo " $0 find [ termselection ... ]" echo "" echo "The verify option will attempt to verify each file specified." echo ""