Shell 의 export 명령

3462 단어 shellbashexport
더 읽 기
SHELL 은 사용자 가 [운영 체제] 를 편리 하 게 조작 할 수 있 는 인터페이스 프로그램 이다.
[운영 체제] 에 있어 서 이 인터페이스 프로그램 은 마치 그 밖 에 있 는 케이스 와 같다. SHELL
----------------
다음은 셸 의 기본 명령: export 에 대해 설명 합 니 다.
-----------------
Bash has several commands that comes with the shell (i.e built inside the bash shell).
When you execute a built-in command, bash shell executes it immediately, without invoking any other program.
Bash shell built-in commands are faster than external commands, because external commands usually fork a process to execute it.
In this article let us review some useful bash shell builtins with examples.
1. Bash Export Command Example
export command is used to export a variable or function to the environment of all the child processes running in the current shell.

export varname=value

# exports a function in the current shell.
export -f functionname 

It exports a variable or function with a value.
“env” command lists all the environment variables. In the following example, you can see that env displays the exported variable.

$ export country=India

$ env
SESSIONNAME=Console
country=India
_=/usr/bin/env

“export -p” command also displays all the exported variable in the current shell.
---------------------
===============
How do I use export command under a Linux or Unix-like operating systems to set variables on a bash shell?
You can export shell variables using the export command.
Syntax
The syntax is as follows:

export VAR

You can assign value before exporting using the following syntax:

export VAR=value

OR

VAR=value

export VAR

The export command will marks each VAR for automatic export to the environment of subsequently executed commands i.e. make the local shell variable VAR global.
Examples
To make the local shell variable called PATH type the following:

### export PATH ###
export PATH=$PATH:/usr/local/bin
echo "$PATH"

Set a new EDITOR variable:

export EDITOR=/usr/bin/vim

You need to add export statements to
               ~/.bash_profile or
               ~/.profile or
               /etc/profile
file.
This will export variables permanently:

$ vi ~/.bash_profile

Sample file

PATH=$PATH:$HOME/bin
export PATH
 
# set vim as a text editor
export EDITOR=/usr/bin/vim
 
# set colorful prompt 
export PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '
 
# set java_home
export JAVA_HOME=/usr/local/jdk

To see all a list of all exported variables and functions, enter:

$ export -p

-
15 Useful Bash Shell Built-in Commands (With Examples)
http://www.thegeekstuff.com/2010/08/bash-shell-builtin-commands/
Use export Command in Linux / Unix
https://www.cyberciti.biz/faq/linux-unix-shell-export-command/
-

좋은 웹페이지 즐겨찾기