Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Bash basic Command referenc

Shulou Source: shulou.com Published: 2022-06-03 06:36:35 11月23日 Update

If

Syntax: help if

If COMMANDS; then COMMANDS; [elif COMMANDS; then COMMANDS;]... [else COMMANDS;] fi

File related:

1. If [- f file]: whether to ask the file (return false does not exist)

2. If [- d dir]: whether it is a directory

3. If [- e file]: whether the file (directory) exists

4. If [- r file]: whether it is readable

5. If [- w file]: whether it is writable

6. If [- x file]: whether it is executable

7. If [- s file]: whether it is an empty file

8. If [- S file]: whether it is a Socket file

Compare size (integer variable)

1. If [a-eq b]: whether it is equal or not

2. If [a-ne b]: whether it is different or not

3. If [a-ge b]: greater than or equal to

4. If [a-gt b]: greater than

5. If [a-le b]: less than or equal to

6. If [a-lt b]: less than

String comparison

1. If [a = b]: whether it is equal

2. If [a! = b]: whether it is unequal

3. If [- n str]: non-empty

4. If [- z str]: empty

5. If [str]: non-empty, similar to-n

Logical operation (not yet verified)

1 、 if [! Exp]: not

2. If [!-d $dir]: directory does not exist

3. If [exp1-an exp2]: and

4. If [exp1-o exp2]: or

For

Syntax: help for

For ((exp1; exp2; exp3)); do COMMANDS; done

For NAME [in WORDS...]; do COMMANDS; done

Example:

For ((iTuno; I

Tags: Parameters files directories syntax instances commands numbers variables names sizes characters strings not yet integers scripts logic problems operations validation fundamentals Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia Apple MariaDB Redmi