Article title: describes a few shell tips. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. system environment variables after the user logs on to the system:
$ HOME user's own directory
$ PATH: the directory to be searched during command execution
$ TZ time zone
$ MAILCHECK the number of seconds to check whether a new letter exists
$ PS1 prompt number in the command column
$ PS2 indicates the prompt number when Shell requests to re-input when the command has not been completed
$ MANPATH man command search path
II. special variables:
$0 execution name of the program
$ N the nth parameter value of this program, n = 1 .. 9
$ * All parameters of this program
$ # Number of parameters of this program
$ PID of the program
$! PID used to execute the previous command
$? The return value of the previous command.
3. variable in shell:
* Any string
? Any character
[Abc] one of the three: a, B, and c
[A-n] any character from a to n
4. Special characters
\ B return
\ C is often used to print a row without line breaks.
\ F Form Feed
\ R press enter
\ T tabulation
\ V vertical tabulation
\ Backslash itself
V. determining file attributes
Format:-operator filename
-If the file-e exists, 1 is returned; otherwise, 0 is returned.
-If the r file is readable, 1 is returned; otherwise, 0 is returned.
-W file write return 1, otherwise return 0
-1 is returned for executable-x files; otherwise, 0 is returned.
-O: If the file belongs to the user, 1 is returned; otherwise, 0 is returned.
-If the length of the z file is 0, 1 is returned; otherwise, 0 is returned.
-If the f file is a normal file, 1 is returned; otherwise, 0 is returned.
-If the d file is a directory file, 1 is returned; otherwise, 0 is returned.
6. test the string
String 1 = String 2 true when two strings are equal
String 1! = String 2: true when two strings are not equal
-N string: true when the string length is greater than 0
-Z string: true when the string length is 0
String is true when the string is not empty
7. test the relationship between two integers
Number 1-eq number 2 equal to true
The number 1-ne number 2 is not true.
Digit 1-gt digit 2 digit 1 greater than digit 2 True
Number 1-ge number 2 number 1 greater than or equal to number 2 True
Number 1-lt number 2 number 1 less than number 2 True
Number 1-le number 2 number 1 less than or equal to number 2 True
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service