请编写一个1.sh脚本。 1.sh的执行方式为:sudo minicom -S 1.sh -C 1.txt 功能是:通过“sudo minicom -S 1.sh -C 1.txt”执行脚本后,会执行“show running-config",将此时终端所有输出的信息全都输出到1.txt文件中,按esc后enter。 1.txt存放位置为本目录
时间: 2024-01-02 07:03:55 浏览: 47
好的,以下是满足你需求的1.sh脚本:
```bash
#!/bin/bash
# 执行 show running-config 命令并将输出保存到 1.txt 文件中
echo "show running-config" | sudo minicom -S -C 1.txt
```
将上述脚本保存为 `1.sh`,然后在终端中运行以下命令给予执行权限:
```bash
chmod +x 1.sh
```
接下来,你可以在终端中执行以下命令来运行脚本,并将输出保存到 `1.txt` 文件中:
```bash
sudo minicom -S 1.sh -C 1.txt
```
执行完成后,`1.txt` 文件将会在当前目录下生成,并包含终端中执行 `show running-config` 命令的输出内容。按下 "ESC" 键然后按 "Enter" 键以退出 minicom。