I have this code that works perfectly on one Macbook but doesn't work on another Linux machine in bash. When run in the Linux machine, I get an error "conditional binary operator expected" "syntax error near ${testfile}'" when trying to check if the file in the variable is readable or a file.
for file in "${@:2}"
do
if [[ ! -rf ${file} ]]
when I make it [ ! -rf "$file" ] I get: [: -rf: unary operator expected
-rfdoes indeed seem to work on my MacBook but I have no idea what it's supposed to do, and I get the same error when I try it on a random old Debian box where presumably I have an older version of Bash. What's the actual purpose of this script?[[ ! -r $file -a ! -f $file ]]which of course then should be portable back to Bash v2 and possibly beyond.syntax error near-a' @tripleee[[ ! -r $file && ! -f $file ]]but I'm still guessing here. Can you confirm that you are trying to check that the file exists and is a regular file and is readable?