- 11
- 0
- 约1.54万字
- 约 14页
- 2017-09-01 发布于河南
- 举报
怎样编写脚本程序入门(How to write a script entry)
怎样编写脚本程序入门(How to write a script entry)
How to write a script based on articles 1.1 (1) introduced the basic grammar at the beginning of the 1.1.1 program must begin with the following line (must be in the first line of the file): #! /bin/sh symbol #! To tell the parameters of the system after it is used to execute the program file. In this example, we use /bin/sh to execute the program. When you edit a script, you must also make it executable if you want to execute the script. To make the script executable: compile Chmod +x filename to be able to use the./filename to run the 1.1.2 annotation in shell programming, to # at the beginning of the sentence annotation, until the end of the line. We sincerely recommend that you use notes in your program. If you use the annotation, you can understand the function and working principle of the script in a very short time even if you do not use the script for quite a long time. 1.1.3 variables, in other programming languages, you must use variables. In shell programming, all variables are made up of strings, and you dont need to declare variables. To be assigned to a variable, you can write this: #! /bin/sh # of variable assignment: a= Hello world # now print the contents of variable a: A echo is: echo $a sometimes variable names are easily confused with other characters, such as: num=2 echo this is the $numnd that will not print this is the 2nd , and this is the just print, because shell will go to search the value of numnd, but this variable has no value.
You can use braces to tell shell that we want to print the num echo this is variable: num=2 the nd this is: this will print the 2nd 1.1.4 environment variable by the export keyword treated variables called environment variables. We dont discuss environment variables, because typically only environment variables are used in login scripts. The 1.1.5 Shell command and flow control can use three types of commands in the shell script: 1) Unix command: Although you can use any UN
您可能关注的文档
- 常用文言虚字(The commonly used classical Chinese function words).doc
- 常用日语中文发音(Japanese pronunciation).doc
- 常用材质、贴图(Common materials, textures).doc
- 常用显示接口(Common display interface).doc
- 常用正则php100总结(Commonly used regular php100 summary).doc
- 常用日语1000句——中日双语对照(转自网络)(1000 sentences commonly used in Japanese Chinese and Japanese bilingual comparison (from network)).doc
- 常用法律条款刑事诉讼法(Common law clause Criminal Procedure Law).doc
- 常用物理单位换算(Conversion of commonly used physical units).doc
- 常用瑜伽动作(Yoga routines).doc
- 常用电子仪器使用(Commonly used electronic instruments).doc
原创力文档

文档评论(0)