Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use the source command of linux to read and execute commands from a specified file in the current Shell environment

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the use of linux source commands in the current Shell environment to read and execute commands from specified files, the article is very detailed, has a certain reference value, interested friends must read it!

The source command (from C Shell) is a built-in command for bash shell. The dot command, which is a dot symbol (from Bourne Shell), is another name for source. The source command is typically used to re-execute the initialization file that you just modified to take effect immediately without having to log out and log back in.

Source returns the return value of the last command in the file, which fails if the file cannot be read.

Syntax format: source [file]

Reference example

Read and execute the / root/.bash_profile file:

[root@linuxcool] # source ~ / .bash_profile

Execute the initialization file you just modified to take effect immediately:

[root@linuxcool ~] # source / etc/bash_profile

During the execution of some tools, the environment variable settings are exported to a file in the form of "export XXX=XXXXXX" or "declare XXX=XXXXXX", and then the contents of the file are loaded into the execution environment with source:

[root@linuxcool ~] # vi / etc/profile [root@linuxcool ~] # source / etc/profile

If you make these commands into a file and let it execute automatically and sequentially, it will be very convenient for users who need to compile the core of the system many times, and you can do this with the source command. Its function is to execute the contents of a file as shell. First, create a file, such as make_command, in the source code directory of linux (such as / usr/src/linux-2.4.20), and enter the following contents:

Make mrproper & &

Make menuconfig & &

Make dep & &

Make clean & &

Make bzImage & &

Make modules & &

Make modules_install & &

Cp arch/i386/boot/bzImage / boot/vmlinuz_new & &

Cp System.map / boot & &

Vi / etc/lilo.conf & &

Lilo-v

After the file is created, you only need to type under / usr/src/linux-2.4.20 each time you compile the core:

[root@linuxcool ~] # source make_command above is all the contents of reading and executing commands from the specified file in the current Shell environment using linux's source command. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report