"Must be finished this time" series? Section--linux SHELL script Raiders. (Manual cover face ...) )
1, the simple start. -"The only way to learn a new programming language is to use it to program"
Don't think too much, just tap the code:
[Email protected]:~/ labs#[email protected]: ~/labs# Cat # !/bin/ Bash# # DONT THINK, todo! # Clear Echo " This is my first script. "
The above code should be very "as the name implies", try to execute this script:
[Email protected]:~/labs# SH Myfirstthis is my first script.
2.#!/bin/bashIs it necessary?
This is not a problem with most Linux systems, because the default shell for Linux users is bash, and the script runs with the user's default shell to explain the script (if #!/bin/bash does not write), but many Unix systems may use Bourne sh ell, CSH, or Ksh, as the user's default shell, if the script contains code that matches the bash syntax and makes the other shell impossible to interpret, then it must be written on the first line (and, of course, Bash is installed on the system) to keep the script running properly. --by Minsic (2009)
3, in order to ensure that the script can run smoothly! ——chmod 755 Your-script-name
Linux in various types of files are very privileged, this permission is a bit cumbersome, and change the permissions of the method is particularly many, but, for the moment, I think the title of the article is good:
(It will soon be forgotten anyway, don't ask me why.) )
[Email protected]:~/labs# chmod 755 [email protected]: ~/labs# ls --rwxr-xr-x1 root root 7 Oct myfirst:
This command allows the computer to change the permissions of the Myfirst to: not writable except me! (Can see, can execute, just can't write!) "I" is who invites themselves to think ~
Then two black and white words are related, temporarily leave an impression on OK.
30 minutes per day.
Next section: Variables
"LINUX SHELL" Note 01: Don't think, do it!