Looking for a little help parsing some command line arguments in a bash script I am working on, this is probably fairly basic to most, but I do not have much experience with it.
At the command line, when the script is run, I need to make sure the argument passed is a file, it exists in the current directory, and that there is only one argument.
Here is the code I am using for this task now, but it does not produce the result I need:
Your version [ -f $1 -a $# -eq 1 ] give error if you don't give any arguments, because $1 is empty, but if you put -f "$1" then value is some string, maybe very short (len 0).
Why ? Read full story