Fifth classroom summary --shell

Review before class
embedded Linux development tools: -gcc, gdb, make
learning objectives: understanding gdb, write makefile
job: Master Control Makefile, function directory Makefile, scripts of
about shell
the lesson content:
automatically generated: CMake autotool
Embedded Linux development tools -shell programming (script: batch)
Linux system operation and maintenance engineer (embedded system development - system migration)
What is the shell
1. command parser (parsing commands entered by the user, call the appropriate command executable file)
2 script language (script: batch)
shell is both a command language is a programming language that provides a number of control structures in higher-order language that has the.
Execute the command: / bin / sbin / environment variables
exact point that, Shell is a command-line interpreter, its role is to follow a certain command syntax will be explained and passed to the input of the system. It provides an interface for system-level program sends a request to run a program to Linux users, the user can use the Shell to start, suspend, stop or even write some programs.
Shell is both a command language is a programming language. As a command language commands which interpret and execute interactive user input; as a programming language that defines variables and parameters, and provides a number of control structures that has the higher order language, including looping and branching.
shell basic language
beginning of the program:! # / bin / sh
script executable: chmod + x filename
to execute the script: ./ filename
shell variable
details ppt reference to class
when you define a variable, the variable name without the dollar sign $
your_name = "cxx.com" Note that there is a space between the variable name and the equal sign, which may be familiar to you and all programming languages are not the same. Meanwhile, the name of the variable name must follow these rules:
1, named only letters, numbers and underscores, the first character can not start with a number.
2, without spaces, you can use underscores (_). You can not use punctuation.
3, bash where keywords can not be used.
PPT content:
! # / Bin / SH # for variable assignment: a = "hello world" now print variable a content: echo "A is:" echo $ a enter the above text in the editor, and then save it as a file HelloWorld. After executing chmod + x HelloWorld entered last ./ HelloWorld execute the script. This script will output: A is: hello world Sometimes variable names easily confused with other names, such as: S13: num = 2echo "this is the $ numnd"
thinking: Output? ? Why num = 2echo "this is the KaTeX parse error: Expected '}', got 'EOF' at end of input: ..." this is the {num} nd " This will print:" this is the 2nd "

The default variable
$ # script command-line arguments passed number
$ * All command-line parameters, leaving a space between each parameter value of $ 0 command itself (shell filename) $ 1 the first command line parameter $ 2 second command line parameter at the command followed by the command-line parameters:
local variables:
plus local keyword what a local variable, for example, S3 when the variable is first copied:
! # / bin / bashhello = "var1" func1 {echo $ hellofunction the Hello local = "var2" Hello echo $ $} func1echo Hello
the shell basis statement the -if, for, the while
iF statement:
example:
comparison of integers a and b are equal integers: if [$ a = $ b ]
comparison of the integer a is greater than an integer b: if [$ a -gt $ b] ratio of
a and b are equal to more strings: if [$ a = $ b ]
determines whether a string is empty: if [-z $ a]
Comparative integer variable a is greater than b: IF [-gt $ a $ B]
for statement:
for loop and the C language is different, the basic structure of the BASH for loop is:
for var in [list] do # code blockdone where var is the loop control variable, [List] var is a need to be traversed to set, do / done loop contains, c language equivalent braces. Also do and for being on the same line, and must be preceded do ";" such as: for var in [List]; dos7:! # / Bin / bashfor Day in Sun Mon Tue Wed Thu Fri Satdoecho $ daydone
the while statement:
while statement
while [for condition Condition]
do
#code Block
DONE

Published 10 original articles · won praise 0 · Views 267

Guess you like

Origin blog.csdn.net/m0_46451503/article/details/105211568