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.
Syntax:
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:

Options:
- -p This is used to displays the options and attributes of each variable name if it is used with name arguments.
Example:
- -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:
Recommended Posts:
- fg command in Linux with examples
- sum command in Linux with Examples
- tar command in Linux with examples
- wc command in Linux with examples
- cmp Command in Linux with examples
- apt-get command in Linux with Examples
- rev command in Linux with Examples
- gdb command in Linux with examples
- dir command in Linux with examples
- yes command in Linux with Examples
- env command in Linux with Examples
- ps command in Linux with Examples
- arp command in Linux with examples
- look command in Linux with Examples
- rm command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




