Hi,
I need to perform the untar and rm operation if the file found is a .tar and does not have test.tar or hello.tar as the file names.
Below is the loop to check the same.
for tf in *.tar
do if [[ ( -f "$tf" ) && ( "$tf" != test.tar || "$tf" != hello.tar ) ]]
then found=1
echo "UNTAR THIS:"$tf
tar xvf "$tf" && rm -rf "$tf"
ec=$?
if [ $ec -ne 0 ]
then exit $ec
fi
else
echo "DONT TOUCH THIS TAR:"$tf
fi
done
However, when I run the script in debug mode it is only checking the condition "$tf" != test.tar
and ignores this check "$tf" != hello.tar
So it untars and removes hello.tar when it was suppose to ignore it.
Can you please suggest.