Linux Beginner Note nine: Linux I/O management, redirection and plumbing! (Video serial number: 04_3)

Source: Internet
Author: User
Tags arithmetic stdin

commands to learn in this section:TR,TEE,WC

Skills learned in this section:

The composition of the computer

I/O Management and redirection

Use of pipelines

 

Knowledge Point nine: Management and IO redirection (4_3)

Computer composition:

Arithmetic, controller: CPU

Memory: RAM

Input device/Output device

  Programs: Directives and data

Controller: reads the instruction and reads the operation and data to be performed under the control of the instruction

The arithmetic device:

Memory:

Address bus: Memory addressing

Data bus: Transferring data

Control Summary: Control command data

Register: CPU Ephemeral memory

I/O: (e.g. hard disk, monitor, mouse, etc.)

Input device: Enter device

Output device: Export device

  System default Device Settings:

Default output device: Standard output, STDOUT, 1

Default input device: standard input, STDIN, 0

Standard error Output: STDERR, 2 (with a different data stream)

Standard input: Keyboard

Standard output and Error output: Display

I/O redirection:

Linux:

   : Output REDIRECT symbol:

: Overwrite output

>>: 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.

    <: Enter REDIRECT symbol:

' A- z ' ' A- z ' </etc/profile

    <<:here document to generate documents here

cat << endthe first line,the second line. ENDcat >>/etc/myfile.txt <<eofthe first line,the second line. EOFCat /etc/myfile.txt

Pipeline:

The output of the previous command, as input to the latter command

Format: Command 1 | Command 2 | Command 3 | ...

--Pipe Echo'Hello Word'Echo'Hello Word'| Tr'A- z' 'A- z'--turn Hello word into uppercase and outputEcho'Redhat'| passwd--stdin hivecut-D:-f1/etc/passwd | Sort | Tr'A- z' 'A- z'--Sort the user name (1 columns) of the passwd file and turn it into uppercasels/var | Tr'A- z' 'A- z'----------------Tee reads data from standard input and sends to standard output and file echo"Hello Word"| tee/tmp/hello.out--Send Hello Word to standard output and save in file----------------WC--displays the number of rows of a file WC-L/ETC/PASSWD--not only shows the number of lines of the file but also the filename WC-l/etc/passwd | Cut-d' '-F1--implements the Cat/etc/passwd | WC-L--displays the number of rows in the directory LS/usr/bin | Wc-l

After-school assignments:

Practice:1. Statistical/usr/bin/the number of files in the directory;#Ls/usr/bin | wc-l2, the shell of all the users on the current system is removed, and each shell is displayed only once, and is displayed sequentially;#cut-d:-f7/etc/passwd | sort-u3, thinking: How to display/var/What is the content type of each file in the log directory? #file/var/log/*#cd/var/log/| file ' ls/var/log/'4. Remove/etc/the 6th line of the Inittab file;#head-6/etc/inittab | tail-15. 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/tmp/the users file;#tail-9/etc/passwd | head-1 | cut-d:-f1,7 | tee/tmp/users6. Display/all files beginning with PA in the ETC directory, and count the number of them;#ls-d/etc/pa* | wc-l7, do not use a text editor, will alias Cls=The clear line is added to the current user's. bashrc file;#echo "Alias Cls=clear" >> ~/.BASHRC

Linux Beginner Note nine: Linux I/O management, redirection and plumbing! (Video serial number: 04_3)

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.