To check for multiple files, you can use a loop or a conditional statement. Here’s an example using a loop in a bash script:
files=("file1.txt" "file2.txt" "file3.txt")
for file in "${files[@]}"; do
if [ -f "$file" ]; then
echo "$file exists."
else
echo "$file does not exist."
fi
done
Alternatively, you can use a single conditional statement with the && operator:
if [ -f file1.txt ] && [ -f file2.txt ] && [ -f file3.txt ]; then
echo "All files exist."
else
echo "One or more files do not exist."
fi
Choose the method that best fits your needs!
