Pipe character redirection
Pipe command character
Pipe command symbol " | " is the role of the previous command to the standard output after the command as a standard input , the format of " command A | command B ."
Zhusaiwei-hbza to send an e-mail users:
[root@zhusaiwei-hbza ~]# echo "Content" | mail -s "Subject" zhusaiwei-hbza
Input and output redirection
For these cases the output redirection operator:
symbol |
effect |
Command> file |
The standard output to a file (original file data is empty) |
Command 2> file |
The error output is redirected to a file (clear the data of the original file) |
Command >> file |
The standard output to a file (appended to the original content) |
2 file command >> |
The quasi-error output redirected to a file (appended to the original content) |
Command >> file 2> $ 1 |
The standard output and error output jointly written to a file (appended to the original content) |
For input redirection of these situations:
symbol |
effect |
Command <file |
The standard input file as a command |
Command << delimiter |
Reads from standard input, until she met "delimiter" stopped |
Command <Document 1> File 2 |
The command file as a standard input and standard output to the file 2 |
The help file is written to the man command in /root/man.txt:
[Root @ zhusaiwei-hbza ~] # man bash> /root/man.txt
To write a line of text readme.txt file:
[root@zhusaiwei-hbza ~]# echo "Welcome to LinuxProbe.Com" > readme.txt
To an additional line of text in readme.txt:
[root@zhusaiwei-hbza ~]# echo "Quality linux learning materials" >> readme.txt
View the contents of readme.txt:
[root@zhusaiwei-hbza ~]# cat readme.txt
Welcome to LinuxProbe.Com
Command line through Hythe
Bash supports a variety of text interpreter wildcards include:
Tsuhaifu |
meaning |
* |
Matches zero or more characters. |
? |
Matches any single character. |
[0-9] |
Matching number in the range. |
[abc] |
Matches any character already out. |
View beginning sda all device files:
[Root @ zhusaiwei-hbza ~] # ls / dev / sda *
/ Dev / sda / dev / sda1 / dev / sda2
Check back sda there is a character device file:
[Root @ zhusaiwei-hbza ~] # ls / dev / sda?
/dev/sda1 /dev/sda2
Check back 0-9 sda contains device files:
[Root @ linuxprobe ~] # ls / dev / sda [0-9]
/dev/sda1 /dev/sda2
Check back sda is the device file 1 or 3 or 5:
[Root @ zhusaiwei-hbza ~] # ls / dev / sda [135]
/dev/sda1
In addition bash interpreter also supports many special characters extensions:
character |
effect |
\ (Backslash) |
Escape single character behind |
''(apostrophe) |
Escape all characters |
""(Double quotes) |
Variable remains in effect |
`` (Backtick) |
Execute command statement |
Define a variable PRICE is 5:
[root@zhusaiwei-hbza ~]# PRICE=5
Want output "Price is 5":
[root@zhusaiwei-hbza ~]# echo "Price is $PRICE"
Price is 5
Want output "price is $ 5," but because the dollar sign and the variable representing the value of the $ symbol collision, so the error:
[root@zhusaiwei-hbza ~]# echo "Price is $$PRICE"
Price is 3767PRICE
Add a backslash, the first $ Escape symbol:
[root@zhusaiwei-hbza ~]# echo "Price is \$$PRICE"
Price is $5
Use single quotes, the variable will no longer be values:
[root@zhusaiwei-hbza ~]# echo 'Price is \$$PRICE'
Price is \$$PRICE
Implementation of the uname -a can view native kernel version and architecture information (backticks inside the command is executed):
[Root @ zhusaiwei-hbza ~] # echo `uname -a`
Linux zhusaiwei-hbza.com 3.10.0-123.el7.x86_64 #1 SMP Mon May 5 11:16:57 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux