Difference between revisions of "$1"
Jump to navigation
Jump to search
(Created page with " * {{Bash}}") |
|||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash | ||
+ | [[if]] [ [[-n]] "$1" ]; then | ||
+ | echo "You supplied the first parameter!" | ||
+ | else | ||
+ | echo "First parameter not supplied." | ||
+ | fi | ||
+ | |||
+ | [[if]] [ [[-z]] "$1" ]; then | ||
+ | echo "First parameter not supplied." | ||
+ | echo "Usage: XXXXX" | ||
+ | [[exit 0]] | ||
+ | fi | ||
+ | |||
+ | == Related == | ||
+ | * <code>[[echo $0]]</code> | ||
+ | * <code>[[ARG]]</code> in <code>[[Dockerfile]]</code> | ||
+ | * <code>[[$@]]</code> | ||
+ | |||
+ | == See also == | ||
* {{Bash}} | * {{Bash}} | ||
+ | |||
+ | [[Category:Bash]] |
Latest revision as of 15:05, 27 September 2024
https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
if [ -n "$1" ]; then echo "You supplied the first parameter!" else echo "First parameter not supplied." fi
if [ -z "$1" ]; then echo "First parameter not supplied." echo "Usage: XXXXX" exit 0 fi
Related[edit]
echo $0
ARG
inDockerfile
$@
See also[edit]
Bash [ -c ]
,alias
,&&
, Bash history, Autocompletion,set
,unset
,export
,.bash_aliases, .bashrc and .bash profile
,PS1
,echo
,brace expansion
, Function,shopt
,trap
,set -e
,source
,PATH
,complete
,disown
,.hushlogin
,.bashrc
,builtin
,eval
,set
,$PATH
,$HOME
,TZ
,.profile
,-e, -i
,Builtin (Bash)
,mapfile
,~
, return (Bash), for, until,declare, dirname, basename, functions.sh
, Bash arithmetic expansion,shift, bash --rcfile, readonly, $1, $@
Advertising: