Xiao Q: A person's career success is only% 15 due to his professional skills, and the other% 85 depends on his interpersonal
Relationship. Extraterrestrial skills; soft and hard are relative, professional skills are hard skills, and based on dealing with interpersonal relationships
The communication skills are soft skills --- Carnegie
1: Introduction
Two: shell script format
Three: shell execution mode
Four: shell view
Five: shell variables and examples
1: Introduction
Script languages: Script languages are computers created to shorten the traditional writing-compiling-linking-running process
Programming language; is a scripting language higher than HTML hypertext markup language and lower than c · java programming language;
Generally exists in text form, similar to a command, does not require compilation;
Features: The program code is both a script program and a final executable file.
Classification: Independent: completely depends on the interpreter during its execution;
Embedded: Usually used in programming languages (such as C, C ++, VB, Java, etc.).
For example:
If you create a program, you can open the file with the extension .aa. When someone writes the .aa file, the script can automatically operate on it.
classification:
1. Work control language and shell
2.GUI script: a professional control computer language; interaction between the user and the graphical interface.
3. WEB programming script: Application-specific scripting language for providing custom functions of WEB pages.
4. Application-specific scripting languages: Many large-scale applications customize customary scripting languages based on user needs.
5. Text processing language: Processing text-based records is one of the earliest uses of scripting languages. awk perl
6. Universal dynamic language: Some languages, such as Perl, have evolved from a scripting language to a more general programming language.
7. Extension / embeddable languages: A few languages are designed to replace application-specific scripting languages by embedding applications.
Common scripting languages:
1. C shell: Bill Joy developed the C shell at the University of California, Berkeley in the early 1980s.
2.JavaScript: A translatable web scripting language that has been widely used in web application development, and its interpreter is called
JavaScript engine as part of the browser
3.Python: is an object-oriented, interpreted computer programming language, Guido van Rossum in 1989
Invented, nicknamed the glue language, it is convenient to connect programs such as c · c ++
4.PHP: is a universal open source scripting language. The syntax absorbs the characteristics of C, Java, and Perl, which is conducive to learning and makes
Widely used, mainly applicable to the field of Web development
5.Perl: A feature-rich computer programming language that runs on more than 100 computer platforms; designed by Larry
· Larry Wall, published on December 18, 1987
6. Nuva: It is an object-oriented dynamic scripting language that is used outside the field of code generation. The Nuva language can also be used for development.
application
7. Ruby, a scripting language created for simple and fast object-oriented programming (object-oriented programming)
shell
Shell: Commonly known as the shell (used to distinguish it from the core), refers to software that "provides a user interface" (ie, a command parser)
It is similar to command under DOS and later cmd.exe.
Two categories
Graphical interface shell: (ie GUI shell), applied to Microsoft's Windows series operating system and Linux shell package
Including X window manager and more powerful CDE, GNOME, KDE, XFCE;
Command-line shell: (ie CLI shell) such as bash / sh / ksh / csh (Unix / linux systems) and MS-DOS
System
Command line shell
1.bash: GNU Bourne-Again Shell, generally the default shell in Linux;
2.csh: c shell, invoke c interpreter;
3.ksh: korn shell, AIX command;
4.sh: shell, invokes the default shell.
Features
Nowadays, all work is turned to automation, and the same is true for operation and maintenance. For automated operation and maintenance, scripting is essential. Now most of Linux uses bash by default. He is relatively excellent in programming and compatible with several others. bsh, we mainly learn bash.
As a qualified staff member, you must first archive your own scripts and categorize them, that is, place them in a specific directory, and then categorize your own script categories. The names are easy to understand and suffixed with .sh
format:
#! / bin / bash
## Script creator
## Script creation date
## A few additional notes
## Script functions
The original text ...
problem:
1. Enter a series of commands in the file, can they be executed directly?
Yes; I think the shell used by the current user is called by default. If one of the commands is wrong
Will continue to execute
2. What is the purpose of adding # / bin / bash, since it is not necessary?
This line is not a comment, but rather the shell under which the script will run and execute the script in that shell environment.
Simple examples to understand: write scripts in the AIX, that is, ksh environment
#! / bin / ksh
##instruction manual
export LOG = / tmp / test.log
exec >> $ LOG 2> & 1
echo "a test message!"
exit 0
After executing the script, a test.log file is generated under / tmp, and the file content is "a test message!"
If you change #! / Bin / ksh to #! / Bin / bash or #! / Bin / bash
When executing the script, the following error will be reported:
export is not a shell command, that is, there is no export command in csh.
1. Switch to the directory where the script is located (that is, the working directory) and execute the shell script:
cd / data / shell >>> ./hello.sh
2. Execute bash shell script with absolute path
/data/shell/hello.sh >>> Enter
3. Use bash or sh directly to execute the -x option to see the process
cd / data / shell >>> bash hello.sh / sh hello.sh
This method does not need to set the shell's execution permissions in advance, and does not even need to write the first line in the shell file (specify bash
Path), because it was specified by bash;
4. Execute in the current shell environment
cd / data / shell >>>. hello.sh
The first three methods are to start a child shell environment to execute the script in the current shell (called the parent shell).
The child shell closes and returns to the parent shell;
The fourth method is to execute the script in this subshell environment, and it will remain in place afterwards.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.