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))
...
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
- A variable modified inside a while loop is not remembered
- What is the difference between $(command) and `command` in shell programming?
- Reading quoted/escaped arguments correctly from a string
- An efficient way to transpose a file in Bash
- Can I export a variable to the environment from a Bash script without sourcing it?
- 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]
- Bash command line and input limit
- How can I split a large text file into smaller files with an equal number of lines?
- Which characters need to be escaped when using Bash?
- Using variables inside a bash heredoc
- When are square brackets required in a Bash if statement?
- Why would a correct shell script give a wrapped/truncated/corrupted error message? [duplicate]
- Test for non-zero length string in Bash: [ -n “$var” ] or [ “$var” ]
- Ubuntu says “bash: ./program Permission denied” [closed]
- Difference between single and double square brackets in Bash
- How to echo shell commands as they are executed
- How to use ‘find’ to search for files created on a specific date? [closed]
- Checking from shell script if a directory contains files
- How to remove files starting with double hyphen?
- How to determine the current interactive shell that I’m in (command-line)
- How to get the primary IP address of the local machine on Linux and OS X? [closed]
- How to redirect output of an entire shell script within the script itself?
- Calling shell functions with xargs
- How to merge two files line by line in Bash
- Count occurrences of a char in a string using Bash
- Compound ‘if’ statements with multiple expressions in Bash
- Fastest possible grep
- How to get script directory in POSIX sh?
- How to search filenames by regex with “find”
- Delete files older than 10 days using shell script in Unix [duplicate]
- Deleting lines from one file which are in another file
- source command not found in sh shell
- Bash regex =~ operator
- Copy folder recursively, excluding some folders
- Variable interpolation in the shell
- How do I pause my shell script for a second before continuing?
- Waiting for background processes to finish before exiting script
- Variables as commands in Bash scripts
- How do I check if a directory exists or not in a Bash shell script?
- Should PATH contain directories or full paths to binaries?
- Is there an elegant way to store and evaluate return values in bash scripts?
- What is a unix command for deleting the first N characters of a line?
- Bash script to receive and repass quoted parameters
- Why would I create an alias which creates a function?
- Subtract two variables in Bash
- Convert Unix timestamp to a date string