Shell common knowledge (1)

Source: Internet
Author: User

1. system environment variables after users log 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
8. Logic Testing

-A and
-O or
! Non


Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.