declare command in Linux with Examples
The declare is a builtin command of the bash shell. It is used to declare shell variables and functions, set their attributes and display their values.
declare [-a] [-f] [-g] [-F] [-x] [-p] [name[=value]] [name[=value]] …
Example: In this example we will declare a variable using declare command.
The output of the above typed commands is as follow:
- -p This is used to displays the options and attributes of each variable name if it is used with name arguments.
- -f : Each name is treated as the name of function, not variable. So you can say this option restrict action or display to function names and definitions.
- -F : When showing information regarding a function, it show only the function’s name and attributes. So the contents of the function will not be displayed.
- -g : It causes all operations on variables to take effect in global scope.
Note: For more details, you can use –help option with “declare” command as follows:
My Personal Notes arrow_drop_up
Please Login to comment...