I. I/O redirection:
System settings
Default output device: Standard output, STDOUT, 1
Default input device: standard input, STDIN, 0
Standard error Output: STDERR, 2
Standard input: Keyboard
Standard output and Error output: Display
Redirect to change the source and destination of the data
1. Output redirection:
> overwrites the contents of the original file
>> Append Output
SET-C: Prohibit overwrite redirection for already existing files;
Force overwrite output, use >|
Set +c: Turn off the above features
2>: Redirect Error output
2>>: Append method
&>: Redirect standard output or error output to the same file
<: Input redirection
<<:here Document
Two. Piping
The output of the previous command, as input to the latter command
Usage: Command 1 | Command 2 | Command 3 | ...
1.echo "Luochen" | Tr ' A-Z ' A-Z
2.echo "Luochen" | passwd--stdin Root
3.cut-d:-f1/etc/passwd | Sort-n | Tr ' A-Z ' A-Z
4.ls/var | Tr ' A-Z ' A-Z
5.tee command obtains data from standard input and saves data to a file at the same time to standard output data
6.wc-l/etc/passwd | Cut-d '-f1
7.ls/usr/bin | Wc-l
Practice:
1, Statistics/usr/bin/Directory of the number of files
# Ls/usr/bin | Wc-l
2. Take out the shell of all the users on the current system, require that each shell be displayed only once, and be displayed sequentially
# cut-d:-f7/etc/passwd | Sort-u
3, thinking: How to display the content type of each file in the/var/log directory
# file ' Ls/var/log '
4. Remove the 6th line of the/etc/inittab file
# head-6/etc/inittab | Tail-1
5. Take out the user name and shell of the 9th user in the/etc/passwd file, display it to the screen and save it to the/tmp/users file.
# tail-9/ETC/PASSWD | head-1 | Cut-d:-f1,7 | Tee >/tmp/users
6. Display all files starting with PA in/etc directory and count them
# ls-d/etc/pa* | Wc-l
7, do not use a text editor, add alias Cls=clear a line of content to the current user's. bashrc file
# echo "Alias Cls=clear" >> ~/.BASHRC
This article is from "Luo Chen's blog" blog, please be sure to keep this source http://luochen2015.blog.51cto.com/9772274/1635498
Introduction to basic commands under Linux (vii)