Learn Common Unix shell commands

Source: Internet
Author: User

Today, let's learn about Common Unix shell commands. We all know that Unix shell is not only a user interaction interface, but alsoProgramDesign Language: when the system registers, it will execute a Unix shell command file. profile, which will give a brief introduction to Common commands in Unix shell.
$ N the nth parameter in the shell command line. N is 0-9. When n is 0, it indicates the command name.
$ # Number of parameters in the command line
$ Process ID of the shell command
$! Code of the last background process
$ * All command line parameters
$ @ Is similar to $ *, but its value is different.
$ Home directory entered during registration
$ PATH command search directory
$ PS1 system's first prompt, usually $
$ Second prompt of PS2 system, generally>
Shift [N] shifts the command line parameter to the left, but $0 remains unchanged.
Variable name = string: Assign the variable name to the string. You can reference this variable with the $ variable name later.
The export variable table passes the variables listed in the variable table to the sub-process.
Read variable table read string from standard input and pass to specified variable
The echo variable table displays the variable specified in the variable table to the standard output.
Set display setting Variables
Env displays all current variables
If condition execution, Syntax:
If condition
Then command
Fi

Case branch execution, Syntax:
Case string variable in
Value 1) command...
Value 2) command...
...
Esac

When the while condition is true, the following statement is used:
While Condition
Do
Command...
Done

When the until condition is a false cycle, the syntax is:
Until Condition
Do
Command...
Done

The for variable loops in the Table. Syntax:
For variable name in Word Group Table
Do
Command...
Done

Break exits from the loop. Syntax: Break n
N indicates the number of layers that exit the loop.

Continue the loop. Syntax: Continue n
N indicates that the nth layer of the loop containing the continue statement is returned.

Exit to exit Shell
The function can be defined in func shell. Syntax:
Func function name ()
{
Command...
}

Expr interprets the string after it as an expression and calculates its value. There must be spaces before and after the operator
Trap capture signal, syntax trap N, capture signal N (for signal description, refer to kill)

Test condition test, syntax test [Option] Parameter options
-F: if the file exists and is readable, the file is real.
-W: true if the file exists and can be written
-X Files are real if they exist and can be executed
-F: if the file exists and is a normal file, it is true.
-D. If the file exists and is a directory file, it is true.
-P file: true if the file exists and is a FIFO file
-S file is true if the file exists and is not empty
-If the length of a Z string is 0, it is true.
-N string: true if the string length is not 0

True if the string is not empty
String 1 = string 2 if string 1 is equal to string 2
String 1! = String 2: true if string 1 is not equal to string 2
If n1-EQ N2 is equivalent to N2
If n1-ne N2 is not equivalent to N2
N1-lt N2 if N1 is less than N2
N1-Le N2: true if N1 is less than or equal to N2
N1-GT N2 true if N1 is greater than N2
N1-ge N2 true if N1 is greater than or equal to N2
Available and non-A or-o! Connect conditional expressions

Common Unix shell commands. We will introduce them here today. Basically, we will introduce some common commands such as UNIX shell. I hope you can learn more.

Related Article

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.