I am trying to create a bash script that iterates a text file wich contains a list of folder names, and checks if any of these folders are missing from a certain path, in this case a directory called 2021.
My list.txt file contains a list like this one:
100001
100002
100003
100004
...
and I have a directory (the so called 2021) that contains sub-folders whos names I want to check
100001
100002
100004
...
Now, in this example, the script should state that folder 100003 is missing.
The purpose of the script is just to find which of the folders listed in the text file are missing from the path
So far, I have:
while IFS= read -r line; do
if [[ ! -d "2021/$line" ]]; then
echo $line is missing
fi
done <<< $(cat list.txt)
but this code just prints all the folders that exist inside 2021 directory, so I am guessing that there is something wrong inside the IF statement, but I can't figure this out.
done < list.txt. 2. Use full paths instead of relative ones, example:"/home/user/2021/$line".