怎样编写脚本程序入门(How to write a script entry).docVIP

  • 11
  • 0
  • 约1.54万字
  • 约 14页
  • 2017-09-01 发布于河南
  • 举报

怎样编写脚本程序入门(How to write a script entry).doc

怎样编写脚本程序入门(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

文档评论(0)

1亿VIP精品文档

相关文档