shell 脚本记录ubuntu 终端输出log
时间: 2023-04-09 08:03:58 浏览: 79
可以使用以下命令将终端输出记录到文件中:
```
script log.txt
```
执行完上述命令后,所有在终端中的操作和输出都会被记录到 log.txt 文件中。要停止记录,可以使用 exit 命令或者按下 Ctrl + D 键。
相关问题
shell 指令记录ubuntu 终端输出log
可以使用以下命令记录 Ubuntu 终端输出 log:
script log.txt
这将在当前目录下创建一个名为 log.txt 的文件,并将终端输出记录到该文件中。要停止记录,可以使用以下命令:
exit
希望这能帮到你!
ubuntu编写shell脚本启动两个终端
可以使用 gnome-terminal 命令启动终端。可以在 shell 脚本中使用该命令启动两个终端。
以下是一个示例脚本:
```
#!/bin/bash
# 启动第一个终端
gnome-terminal -e "bash -c 'echo \"This is the first terminal\"; exec bash'"
# 等待一秒钟
sleep 1
# 启动第二个终端
gnome-terminal -e "bash -c 'echo \"This is the second terminal\"; exec bash'"
```
在这个脚本中,我们使用 gnome-terminal 命令启动两个终端。第一个终端显示 "This is the first terminal",第二个终端显示 "This is the second terminal"。
使用 -e 选项可以指定在新终端中要运行的命令。在这里,我们使用 bash -c 命令来运行一段简单的命令,并在执行完该命令后保持终端打开。 exec bash 命令确保在终端关闭时不会退出 shell。
注意,在启动第二个终端之前,我们在脚本中使用了 sleep 命令等待一秒钟。这是为了确保第一个终端完全启动并显示 "This is the first terminal"。如果不等待,第二个终端可能会在第一个终端之前启动。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)