Linux: 创建并运行 'Hello World' Bash 脚本
在 Linux 中创建并运行 'Hello World' Bash 脚本
本指南介绍如何在 Linux 中创建名为 'hw0_1.sh' 的 Bash 脚本,并运行它以在终端窗口中显示 'Hello World'。
步骤 1: 创建子目录 hw0
在终端窗口中输入以下命令:
mkdir hw0
步骤 2: 进入子目录 hw0
输入以下命令:
cd hw0
步骤 3: 创建名为 hw0_1.sh 的 Bash 脚本文件
输入以下命令:
touch hw0_1.sh
步骤 4: 编辑 hw0_1.sh 文件
使用文本编辑器打开 hw0_1.sh 文件,并输入以下内容:
#!/bin/bash
echo 'Hello World'
步骤 5: 保存并关闭文件
步骤 6: 运行脚本文件
在终端窗口中输入以下命令:
bash hw0_1.sh
现在你应该可以在终端窗口中看到 'Hello World' 的输出。
原文地址: https://www.cveoy.top/t/topic/qCl7 著作权归作者所有。请勿转载和采集!