linux shell helloworld
Hello, World! Tutorial
<!-- /firstHeading --><!-- bodyContent --><!-- tagline -->
From Linux Shell Scripting Tutorial - A Beginner's handbook
<!-- /tagline --><!-- subtitle --><!-- /subtitle --><!-- jumpto --> <!-- /jumpto --><!-- bodytext -->← Other standard shells | Home | Shebang → |
To create a shell script:
- Use a text editor such as vi. Write required Linux commands and logic in the file.
- Save and close the file (exit from vi).
- Make the script executable.
- You should then of course test the script, and once satisfied with the output, move it to the production environment.
- The simplest program in Bash consists of a line that tells the computer a command. Start up your favorite text editor (such as vi):
vi hello.sh
[edit] Essential Vi Commands
- Open a file:
vi filename
- To go into edit mode:
press ESC and type I
- To go into command mode:
press ESC
- To save a file
press ESC and type :w fileName
- To save a file and quit:
press ESC and type :wq
OR
press ESC and type :x
- To jump to a line:
press ESC and type :the line number
- To Search for a string:
Press ESC and type /wordToSearch
- To quit vi:
Press ESC and type :q
Save the following into a file called hello.sh:
#!/bin/bash echo "Hello, World!" echo "Knowledge is power."
Save and close the file. You can run the script as follows:
./hello.sh
Sample outputs:
bash: ./hello.sh: Permission denied
[edit] Saving and Running Your Script
The command ./hello.sh displayed an error message on the screen. It will not run script since you've not set execute permission for your script hello.sh. To execute this program, type the following command:
chmod +x hello.sh ./hello.sh
Sample Outputs:
Hello, World! Knowledge is power.source url:http://bash.cyberciti.biz/guide/Hello,_World!_Tutorial
相關文章
- 13_Linux第一個程式HelloWorldLinux
- linux shellLinux
- Linux Shell程式設計(27)——子shellLinux程式設計
- SpringMVC——HelloWorldSpringMVC
- vue之HelloworldVue
- HelloWorld.phpPHP
- Linux shell日常使用Linux
- Linux Shell變數Linux變數
- Linux Shell指令碼Linux指令碼
- Linux shell 基礎Linux
- Linux shell迴圈Linux
- linux shell重定向Linux
- Linux Shell函式Linux函式
- LINUX Shell 表示式Linux
- linux之shell findLinux
- linux之shell 其他Linux
- Linux shell 指令碼Linux指令碼
- IF 的使用 for Linux ShellLinux
- linux-oracle-shellLinuxOracle
- Linux教程-Turbo Linux Shell(轉)Linux
- 什麼是shell?Linux常用的shell有哪些?Linux
- 什麼是Shell?Linux shell分為幾類?Linux
- Linux Shell程式設計(4)——shell特殊字元(上)Linux程式設計字元
- Linux Shell程式設計(5)——shell特殊字元(下)Linux程式設計字元
- Linux Shell 之 我的第一個Shell程式Linux
- linux Shell 命令列-03-array Shell 陣列Linux命令列陣列
- Flutter系列(四)——HelloWorldFlutter
- Docker之HelloWorld篇Docker
- C#之helloworldC#
- 邁進Java:HelloWorldJava
- Scala的HelloWorld程式
- Linux shell命令總結Linux
- Linux中vim和shellLinux
- Linux 核心、Shell 簡述Linux
- Linux shell基礎3Linux
- Linux shell基礎1Linux
- Linux shell基礎2Linux
- Linux之shell變數Linux變數