I want to check directory 1 8 and 4 present inside a list of parent directory that is passed as argument to the script. PFB my script
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
cd $line
echo "checking in $line" >> ../filesearch.log
if [ [ -d 1] && [ -d 8] && [ -d 4] ]; then
echo "1 8 4 exists" >> ../filesearch.log
else
echo "Dir 1 8 4 does not exist" >> ../filesearch.log
fi
cd ../
done < "$1"
I am getting the below error when i use if [ [ -d 1] && [ -d 8] && [ -d 4] ];
./fs.sh: line 8: [: -d: binary operator expected
if we use [[ -d 1 ]]; instead of if [ [ -d 1] && [ -d 8] && [ -d 4] ]; my code is working fine but my requirement is to check for all the above mentioned files(1 4 8) are present in the parent directory or not.