The -n argument to test (aka [) means "is not empty". The example you posted means "if $1 is not not empty. It's a roundabout way of saying [ -z "$1" ]; ($1 is empty).
You can learn more with help test.
$1 and others ($2, $3..) are positional parameters. They're what was passed as arguments to the script or function you're in. For example, running a script named foo as ./foo bar baz would result in $1 == bar, $2 == baz
Source: parameters - What does -n mean in Bash? - Stack Overflow
No comments:
Post a Comment