Linux 命令行中的子shell、命令类型与历史记录使用指南
1. 子shell的创建与识别
在 Linux 命令行操作中,子shell 是一个重要的概念。有时候,运行 shell 脚本会创建子shell。我们可以通过两种方式来执行一系列命令,下面为你详细介绍。
- 命令列表 :在一行中,使用分号 ; 分隔命令,可依次执行这些命令。例如:
$ pwd ; ls test* ; cd /etc ; pwd ; cd ; pwd ; ls my*
/home/christine
test_file test_one test_two
/etc
/home/christine
my_file my_scrapt my_script my_scrypt
这种方式只是简单的命令依次执行,并非创建子shell。
- 进程列表 :若要创建子shell 执行命令,需将命令用括号 () 括起来,形成进程列表。例如:
$ (pwd ; ls test* ; cd /etc ; pwd ; cd ; pwd ; ls my*)
/home/christine
test_file test_one test_two
/etc
/home/christine
my_file my_scrapt my_script my_scrypt
使用括号
超级会员免费看
订阅专栏 解锁全文
9

被折叠的 条评论
为什么被折叠?



