This should work:
#!/bin/bash
if [ "$#" -eq 0 ] || [ "$#" -gt 1 ] ; then
echo "hello"
fi
I’m not sure if this is different in other shells but if you wish to use <, >, you need to put them inside double parenthesis like so:
if (("$#" > 1))
...
More Related Contents:
- Difference between sh and Bash
- Pass commands as input to another command (su, ssh, sh, etc)
- Validate date format in a shell script
- Are shell scripts sensitive to encoding and line endings?
- Reading quoted/escaped arguments correctly from a string
- What is the cleanest way to ssh and run multiple commands in Bash?
- What is the benefit of using $() instead of backticks in shell scripts? [duplicate]
- How can I remove the extension of a filename in a shell script?
- Is there a list of ‘if’ switches anywhere?
- How can I declare and use Boolean variables in a shell script?
- Test for non-zero length string in Bash: [ -n “$var” ] or [ “$var” ]
- Ubuntu says “bash: ./program Permission denied” [closed]
- How to remove files starting with double hyphen?
- How to get the primary IP address of the local machine on Linux and OS X? [closed]
- How to suppress Terminated message after killing in bash?
- How to make the ‘cut’ command treat same sequental delimiters as one?
- How do I get bc(1) to print the leading zero?
- How does Ctrl-C terminate a child process?
- Copy folder recursively, excluding some folders
- What does it mean in shell when we put a command inside dollar sign and parentheses: $(command)
- What does ” 2>&1 ” mean?
- When should I double-quote a parameter expansion? [duplicate]
- How do I check if a directory exists or not in a Bash shell script?
- Forward function declarations in a Bash or a Shell script?
- Print a file’s last modified date in Bash
- Is there an elegant way to store and evaluate return values in bash scripts?
- Why doesn’t **sort** sort the same on every machine?
- How to properly nest Bash backticks
- How to include nohup inside a bash script?
- Subtract two variables in Bash