Start learning shell

  1. There are two ways to run a shell script:
    1. As an executable program, if in a directory, write a shell script test.sh, you want to execute the script, the script will need to cd into the directory,
      chmod   + the X-./test. SH   # script has execute permission 
      . / the Test. SH   # script execution

      Attention must be written ./test.sh , rather than  test.sh. Run Binary other programs, too, write directly test.sh, linux PATH system will go in search of anyone named test.sh, and only the / bin, / sbin, / usr / bin, / usr / sbin and so on in the PATH your current directory is usually not in the PATH, you will not find written test.sh command, use ./test.sh tell the system that you find in the current directory. 

    2. As the interpreter parameters: directly run the interpreter, that argument is the shell script file name, such as
      /bin/sh test.sh
      /bin/php test.php

  2. shell variables:
    Note: no space between the variable name and the equal sign.

 

Guess you like

Origin www.cnblogs.com/bneglect/p/11355167.html