Variables in Linux. Shell program build, adjust, execute

1. Variables

For the shell, the values ​​of all variables are characters, and the shell program uses [ variable name ] to refer to the value of the variable named [ variable name ] ] 1. Environment variables a . View all environment variables : e n v ; b . Display _ Locally defined environment variables : s e _tc.View an environment variable : echo [variable name];

              --永久:在/etc/profile 中添加export 变量名=变量值
                             2.定义完变量后 source /etc/profile才能使用】

d. Define environment variables:
– Temporary: export variable name = variable value
e. Clear environment variables: unset [ variable name ] f.Predefined variables : _ _ ?: Return status after command execution
$$: Current process number
$0: Current process name
g. Variable expression
– string comparison;
– digital comparison: -eq equal
-ne not equal
-ge greater than or equal/greater than equal /
-le is less than or equal to /less than equal/
-gt is greater than
-lt is less than
! non
-logical test: -! Opposite of a logical value
- a (and) is true only if both are true
- o (or) is true if one is true
- file operations: -d: object exists and is a directory
-f: object exists and is a file
-rwx : The object exists and is readable, writable, and executable

Second, the shell program establishment, debugging, execution

[The shell program contains:
Beginning: #! /bin/bash [! Indicates that the shell is running! The following commands use the rest of the document as input];
Comments: #filename:~;
statement execution part;]
1. Build: touch to create a file >> vi edit content >> chmod u+x /chmod 744 (change the file to readable Execute)
2. Debug: bash -evx [absolute path to the shell program file]
[-e Exit if there is a command error
-v Both the original command line and the replacement content are displayed
-x The original command line has + at the beginning of the line]
3. Execute: [ Three kinds]
a.bash [absolute path of shell program file] [calling the new bash command interpreter, passing the file as a parameter]
b.bash<[absolute path of shell program file] (input redirection)
c. file absolute path
[ Note: The general number sequence is: a is easy to use for debugging c]

three, -t view in chronological order
2.pwd view the current directory
3.expr expression (manual command line counter)
spaces separate special symbols with / escape quotation marks

Guess you like