logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Declare Variables - Control Bash Shell Variables | Online Free DevTools by Hexmos

Control Bash shell variables with Declare Variables. Define variable types, scopes, and attributes. Improve script efficiency with this command-line tool. Free online tool, no registration required.

declare

Declare variables and give them attributes. More information: https://www.gnu.org/software/bash/manual/bash.html#index-declare.

  • Declare a string variable with the specified value:

declare {{variable}}="{{value}}"

  • Declare an integer variable with the specified value:

declare -i {{variable}}="{{value}}"

  • Declare an array variable with the specified value:

declare -a {{variable}}=({{item_a item_b item_c}})

  • Declare an associative array variable with the specified value:

declare -A {{variable}}=({{[key_a]=item_a [key_b]=item_b [key_c]=item_c}})

  • Declare a readonly string variable with the specified value:

declare -r {{variable}}="{{value}}"

  • Declare a global variable within a function with the specified value:

declare -g {{variable}}="{{value}}"

  • Print a function definition:

declare -f {{function_name}}

  • Print a variable definition:

declare -p {{variable_name}}

See Also