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
相關文章
- Linux ShellLinux
- 13_Linux第一個程式HelloWorldLinux
- Linux/Go環境搭建, HelloWorld執行LinuxGo
- Linux shell日常使用Linux
- Linux Shell變數Linux變數
- Linux Shell指令碼Linux指令碼
- helloworld
- Linux 核心、Shell 簡述Linux
- Linux的shell環境Linux
- 【Linux shell】while read lineLinuxWhile
- Linux中vim和shellLinux
- Linux shell命令總結Linux
- Linux 修改 預設 shellLinux
- linux shell特殊引數Linux
- Linux之shell變數Linux變數
- Linux shell基礎3Linux
- Linux shell基礎1Linux
- Linux shell基礎2Linux
- linux Shell 命令列-03-array Shell 陣列Linux命令列陣列
- 什麼是shell?Linux常用的shell有哪些?Linux
- 什麼是Shell?Linux shell分為幾類?Linux
- 在Linux中,什麼是Linux shell?Linux
- Linux shell:執行shell指令碼的幾種方式Linux指令碼
- 什麼是shell?Linux中shell有什麼用途?Linux
- Linux下Shell日期的格式Linux
- Linux之shell程式設計Linux程式設計
- linux常用的shell指令碼Linux指令碼
- Linux shell必知必會Linux
- 【linux】Shell中的運算子Linux
- Linux Shell程式設計(1)Linux程式設計
- Linux Shell程式設計(2)Linux程式設計
- FASM之HelloWorldASM
- Servlet-HelloWorldServlet
- dubbo-HelloWorld
- LINUX終端是不是就是SHELL?Linux
- Linux學習之(shell展開)Linux
- Linux學習-shell基礎02Linux
- linux shell指令碼中 =~ 的作用Linux指令碼
- Linux 【Shell指令碼經典案例】Linux指令碼