Source command usage:
Source FileName
Purpose: read and execute the command in FileName in the current bash environment.
Note: This command is usually replaced by the "." command.
For example, source. bash_rc and. bash_rc are equivalent.
The source command (from the C Shell) is the built-in command of the bash shell. The dot command is a dot symbol (From Bourne
Is another name of source. Similarly, the variables configured in the current script will also be used as the script environment. The source (or point) command is usually used to re-execute the initialization of the last modification.
Documents, such as. bash_profile and. profile. For example
If the TERM variable is modified, you can use the source command to re-execute the command in. bash_profile without logging out and logging on again.
For example, if you run export $ KKK = 111 In a script, if you run the script with./a. sh, after the script is executed, you run echo $ KKK
No value is found. If you use source for execution, Then echo
KKK = 111. Because the./a. sh command is called to run the shell in a sub-shell, the structure is not reflected in the parent shell after execution,
Different from source, it is executed in this shell, so we can see the result.
A wonderful use of the source command
When compiling the core, it is often necessary to repeatedly enter a long string of commands, such
Make mrproper
Make menuconfig
Make dep
Make clean
Make bzImage
.......
These commands are long and cumbersome. And sometimes it is easy to lose mistakes, wasting your time and energy. If these commands are made into a file and executed in sequence automatically
Users, It is very convenient. You can use the source command to do this. Its function is to treat the content of a file as a shell for execution. First in/usr/src/linux-
2.4.20 create a file 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 established, after each compilation of the core, you only need to input in the/usr/src/linux-2.4.20
Source make_command
That's all. This file can also be used as a script with only a slight modification. Here is to let everyone understand the usage of source. If you are not using lilo to guide the system, you can remove the last two sentences. Configure your own boot program to guide the new kernel.
Commands in shell programming are sometimes the same as those in C. & Represents and, | represents or. Connect the two commands with &, for example
Make mrproper & make menuconfig
, Indicates that the second command can be executed only after the first command is successfully executed. Commands that have requirements on the execution sequence can ensure that the following commands will not be executed blindly once an error occurs.