source command usage:
source FileName
Function: Read and execute the command in FileName in the current bash environment.
Note: This command is usually replaced with the command “.”.
For example: source .bash_rc is equivalent to . .bash_rc.
The source command (from the C shell) is a built-in command for the bash shell. The dot command is a dot symbol (from the Bourne Shell) is another name for source. Similarly, the variables configured in the current script will also serve as the environment for the script. The source (or dot) command is usually used to re-execute the newly modified initialization documents, such as .bash_profile and .profile. For example, if you modified the EDITER and TERM variables in .bash_profile after logging in, you can use the source command to re-execute the commands in .bash_profile without logging out and logging back in.
For example, if you export $KKK=111 in a script, if you execute the script with ./a.sh, after executing, you run echo $KKK and find no value, if you use source to execute Then echo, you will find KKK=111. Because the call to ./a.sh to execute the shell is run in a subshell, after execution, the structure does not reflect to the parent shell, but the source is different, he is executed in this shell, so you can see the result < Br>
The source command (from the C shell) is a built-in command for the bash shell. The dot command is a dot symbol (from the Bourne Shell) is another name for source. Both of these commands take a script as an argument, and the script will be executed as the current shell environment, ie a new child process will not be started. All variables set in the script will be part of the current shell. Similarly, the variables set in the current script will also be used as the environment for the script. The source (or dot) command is usually used to re-execute the initialization files just modified, such as .bash_profile and .profile. For example, if you modified the EDITER and TERM variables in .bash_profile after logging in, you can use the source command to re-execute the commands in .bash_profile without logging out and logging back in. Like .bash_profile or other similar shell scripts, files can be executed with source or dot commands without executable permissions.
A good use of the source command
When compiling the core, you often have to enter a long list of commands repeatedly, such as
make mrproper
make menuconfig
make dep
make clean
make bzImage
.......
These commands are long and cumbersome. And sometimes it's easy to make mistakes and waste your time and energy. If you make these commands into a file and let it execute automatically in order, it will be convenient for users who need to repeatedly compile the core multiple times. This can be done with the source command. Its role is to treat the contents of a file as a shell. First create a file in /usr/src/linux- 2.4.20 directory, named make_command:
Enter the following content:
make mrproper &&
make menuconfig &&
make dep &&
make clean &&
make bzImage &&
make modules &&
make modules_install &&
cp arch/i386/boot/bzImge /boot/vmlinuz_new &&
cp System. Map /boot &&
vi /etc/lilo.conf &&
lilo -v
After the file is created, each time the kernel is compiled, Just type
source make_command
under /usr/src/linux-2.4.20. This file can also be completely scripted, with a few changes. The main reason here is to let everyone understand the usage of source. If you are not using lilo to boot the system, you can remove the last two sentences. Configure your own bootloader to boot the new kernel.
The commands in shell programming are sometimes the same as C. && means with, |
|
Indicates or. Join the two commands with &&, such as make mrproper && make menuconfig , to indicate that the first command is executed successfully to execute the second command. Commands that require execution order ensure that the following commands will not continue blindly in the event of an error.
Original address http://hi.baidu.com/linuxcer/blog/item/8462d1990827fc0a6e068c14.html
----------------- ------------------------------
-------------- -- My test----------------------
----------------- ------------------------------
1 Create test.sh
#!/Bin/bash
export s=/home/jboss/
2 Execute the command: source test.sh
echo $s
Result output: /Home/jboss/
3 Open a new shell
Execute the command: ./test.sh
echo $s
Result: No output s value
To open a previously compiled normal project (created with IAR5.5), the following error is reported
Requirement scenario Using the proxy server HAProxy to load balance Mysql is a common solution. To
The disk sector defaults to 512 bytes. To verify, execute it from the command line: fdisk -l
Today we will learn how to find and remove duplicate files on a Linux PC or server. Here is a tool
The best solution for hard disk partitioning under Linux
Boot is GURB can not enter the system
Common command of vim in Linux
Linux display Chinese directory and file name
Arista Networks is a little different
What is the command apachectl in Linux
CentOS Gearman installation and use error-free version
Linux system capture command tcpdump use instance
How to get the motherboard information under Linux system
Windows 7 SP1 can not be installed 100% solution
Indicator setting for digital lock and case locks
Win10 task manager prompts disk 100% optimization method
Windows 7 system installation VideoStudio 8 tips installed another version how to solve?
Win10 disk takes up 100% solution
The search box in the win7 start menu is gone. How to do
Microsoft has already transformed! Windows 10 doesn't make money, but it can be free forever
How does the Win10 system always automatically generate the Sandbox folder?
Windos defender how to turn off Win10 to disable the virus protection prompt method