FreeKB - Linux commands declare command
Linux commands - declare command

declare can be used to determine if a variable or array has been defined. In this example, declare is used to determine if the foo variable has been defined.

declare -p foo

 

If the foo variable has not been defined, something like this should be returned.

bash: declare: foo: not found

 

If the foo variable has been defined, something like this should be returned. Two dashes (--) suggests that foo is a variable.

declare -- foo="bar"

 

If the foo array has been defined, something like this should be returned. -a means that foo is an array.

declare -a foo='([0]="bar")'


Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter e99e1 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |