I'm using Debian 10 (Buster) and am getting an error in a simple Bash script. All it does is check to see if one parameter is passed in, and if it's a file, just echo out the file:
#!/usr/bin/bash if [ ( '$#' -eq 1 ) && ( -f "$1" ) ]; then echo "$1" fi exit 1
I get this error:
line 2: syntax error near unexpected token `'$#'' line 2: `if [ ( '$#' -eq 1 ) && ( -f "$1" ) ]; then'
I have tried every combination of quotes (", ', no quotes) around the
$#, and I always get a variant of those error messages using the type of quotes I use. I can't figure out what it's looking for.