So below is the code i have in my bash script. I'm getting an error saying binary operator expected when i give the command 2 arguments (doesnt give error when i give 1 argument). It does change the file permissions when i give 2 arguments because i can see it when i do ls -l but it still gives me this error. How do i fix it?
for file in $@
do
chmod 755 $file
done
if [ -z $@ ]
then
echo "Error. No argument."
exit $ERROR_CODE_1
fi
i have added this now
if [ ! -f "$*" ]
then
echo "Error. File does not exist"
exit $ERROR_NO_FILE
fi
But now when i enter more than 1 argument it just does everything in the if statement (i.e. prints error.file does not exist) even when the file does exist.