]> arthur.ath.cx Git - backup-script.git/commitdiff
backup-audit: Use find(1) instead of ls(1) to get more comparable output
authorAlexander Barton <alexander.barton@tomas-daily.de>
Fri, 23 Feb 2018 10:03:33 +0000 (11:03 +0100)
committerAlexander Barton <alexander.barton@tomas-daily.de>
Fri, 23 Feb 2018 10:03:36 +0000 (11:03 +0100)
Using ls, the column widths aren't stable, for example ...

bin/backup-audit

index 0264ece56ac19122ce2c8011b8261b9aba042fc2..36c871d4ee1e98dc78c95d30cf9f8ef2b543bae5 100755 (executable)
@@ -79,7 +79,7 @@ ListDirectory() {
 
        local exclude
 
-       exclude='total '
+       exclude=' \.$'
        if [[ "$dir_name" == "/" ]]; then
                exclude="$exclude"'| \.stamp$| dev$| etc$| proc$| root$| run$| sys$| tmp$'
                exclude="$exclude"'| data$| net$| srv$'
@@ -87,8 +87,8 @@ ListDirectory() {
        fi
 
        # shellcheck disable=SC2012
-       ls -Al "$base_dir$dir_name" 2>/dev/null \
-               | egrep -v "($exclude)" | awk '!($2="")' | column -t
+       find "$base_dir$dir_name". -maxdepth 1 -printf '%M %10u:%-10g %t %12s  %f\n' 2>/dev/null \
+               | LC_ALL=C sort -k 9 | grep -Ev "($exclude)"
 }
 
 HandleSystem() {