在自己账户目录下创建子目录hw0所有要检查的文件都放在这个目录下文件名字以hw0开头如hw0_1sh等这时文件的路径应该是: ~hw0hw0_1sh ‘~表示你的账户所在更目录如pi账户那么完整路径就是homepihw0hw0_1sh。Writing Hello World Bash Script that can display Hello World on your terminal wind
To create a subdirectory named "hw0" in your account directory and place the files with names starting with "hw0" in it, you can follow these steps:
- Open your terminal.
- Navigate to your account directory by running the following command:
cd ~ - Create the "hw0" subdirectory with the following command:
mkdir hw0 - Navigate to the "hw0" subdirectory:
cd hw0 - Create a new file named "hw0_1.sh" and open it in a text editor. You can use any text editor of your choice. For example, to create and open the file with the nano text editor, run the following command:
nano hw0_1.sh - In the text editor, write the following Bash script:
This script will display "Hello World" on your terminal window when executed.#!/bin/bash echo "Hello World" - Save the file and exit the text editor. In nano, you can press Ctrl + X, then Y, and finally Enter to save and exit.
- Now, you can execute the script by running the following command:
This will display "Hello World" on your terminal window.bash hw0_1.sh
You can repeat these steps to create and execute other files with names starting with "hw0" in the "hw0" subdirectory
原文地址: https://www.cveoy.top/t/topic/iWkA 著作权归作者所有。请勿转载和采集!