In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the export command in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
How to use the export command of Linux
You can use export in many ways. A common example is the use of export to set up the user environment. Users can simply use export to specify variables and add them to their .profile file. Therefore, each time a user logs in, the environment will be configured in this way.
1. Display all variables of export
When used without any parameters, the export command displays a list of all export variables in the environment. You should be able to view the name of the variable and its corresponding value.
Linuxmi@linuxmi:~$ export
By using the Linux grep command and the export command, you can easily find information about specific variables. The following command uses a simple example to illustrate this.
Linuxmi@linuxmi:~$ export LINUXMI= "Welcome to linuxmi.com" linuxmi@linuxmi:~$ export | grep-I linuxmi
2. Display the export variable of the current Shell
The-p flag of export prints out a list of all exported variables in the current Linux shell. Take a look at the following example to see what this means.
Linuxmi@linuxmi:~$ export-p
You can use this command to troubleshoot various configuration problems with running shell sessions.
3. Export variable under Linux
The export command makes it easy to share variables across environments. You can use the export statement to set the value of a variable. The following example demonstrates this.
Linuxmi@linuxmi:~$ export EDITOR=/usr/bin/gedit
This sets the path of gedit to the value of the editor variable. You can use grep to confirm this.
Linuxmi@linuxmi:~$ export | grep-I EDITOR
4. Export function under Linux
Developers can use the-f option to export functions. The following example demonstrates this using a simple test function. You can use this method to write custom shell scripts.
Linuxmi@linuxmi:~$ test () {echo "Test Function";} linuxmi@linuxmi:~$ export-f test linuxmi@linuxmi:~$ bash Test Function dircolors: / home/linuxmi/.dircolors: there is no file or directory linuxmi@linuxmi:~$ test Test Function
This should display the string "Test Function" in the terminal window. The bash call is used to derive a child process for bash. Otherwise, the test function will not print the text.
5. Configure environment properties
Under the Linux operating system, various environment parameters can be configured using the export command. For example, if you add the following line to the .bashrc file, it will set it to the path of Snap each time the system reboots.
Linuxmi@linuxmi:~$ echo export PATH= "/ snap/bin/lxd:$PATH" > > .bashrc
If you are not familiar with how the configuration file works inside, don't worry. Just add a custom export at the end of the file. That way, you can always find them and delete them if you want.
Thank you for reading! This is the end of the article on "how to use export commands in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.