exec system linux,Linux系统exec命令(Linux system exec command).doc

Linux系统exec命令(Linux system exec command)

Linux系统exec命令(Linux system exec command)

Shell's built-in exec command will not start a new shell, but with the command to be executed by the shell to replace the current process, and will clean up the environment of the old process, and other orders will be executed no longer after the exec command.

So, if you are in a shell, an exec ls, then, after the lists the current directory, the himself out of the shell, because the process of the shell has been replaced with the implementation of the ls command only one process, perform over nature also dropped out. To avoid this influence our use, the exec command in a shell script, use the script to invoke this script, call point can use bash a.s h, (a.s h is to store the command scripts), which can build a sub for a.s h shell to carry out, after the execution to exec, the child script process has been replaced by the corresponding exec command.

The source command or ". "will not create a shell for the script, but just execute the script contained in the current shell.

One exception, however, is that when the exec command is used to manipulate the file descriptor, it does not replace the shell, and when the operation is completed, it will continue to execute the next command.

Exec 3 < & 0: this command will also point the operator 3 to the standard input.

In addition, this command can be used as an option for the find command, as shown below:

(1) in the current directory (containing subdirectories), find all TXT files and find the lines containing the string "bin"

/ - name "*.txt" - exec grep "bin" {} \;

(2) delete all TXT files in the current directory (including subdirectories)

/ -name "*.txt" -exec rm {} \;

To summarize a table:

Exec command action

Exec ls performs ls in the shell, and the ls ends without returning to the original shell

Exec < file takes the contents of file as the standard input of exec

Exec > file writes the contents of the file as standard

Exec 3 < file reads the file into fd3

The content read in so

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值