From 3ac9e52206cba2f11cbadbdbc45e3615820c5257 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 13 Sep 2023 17:13:02 +0200 Subject: [PATCH] Added the option to pass multiple directories --- scan.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scan.sh b/scan.sh index e54c874..d5e8a7d 100644 --- a/scan.sh +++ b/scan.sh @@ -1,16 +1,8 @@ #!/bin/bash -# Check if a directory argument is provided -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -DIR="$1" - -# Ensure the directory exists -if [ ! -d "$DIR" ]; then - echo "Error: $DIR is not a valid directory." +# Check if at least one directory argument is provided +if [ "$#" -lt 1 ]; then + echo "Usage: $0 [ ...]" exit 1 fi @@ -28,5 +20,13 @@ function scan_and_print() { done } -# Start the scan from the given directory -scan_and_print "$DIR" +# Loop through all provided directories and start the scan +for DIR in "$@"; do + # Ensure the directory exists + if [ ! -d "$DIR" ]; then + echo "Error: $DIR is not a valid directory." + exit 1 + fi + + scan_and_print "$DIR" +done