Shell command to read and output data

Source: Internet
Author: User
Shell command to read data and output data [plain] www.2cto. comshell scripts read data in several ways: 1. keyboard Input. default value: 2. read from file 3. the echo function is passed through pipeline commands: \ c: No line feed \ f: paper feed \ t: hop grid \ n: line feed...
The Shell command reads data and the output data [plain] www.2cto.com shell script reads data in several ways: 1. keyboard Input. default value: 2. read from file 3. the echo passing function through pipeline commands: \ c: do not wrap \ f: paper feed \ t: hop grid \ n: line feed \ escape, for example: "\"/dev/rmt0 "\" translated as, "/dev/rmt0" read: reads information from a line of text on the keyboard or file, and assign it to a variable. [Developer]/> read name hello I am a regular user [developer]/> echo $ name hello I am a regular user [developer]/> cat: role, 1. show file content, 2. create a file, 3. display control characters. 1. show the file content cat filename | more cat filename | pg 2. create a file cat> filename 3. display Control character cat-v filename pipe: you can use the pipe to pass the output of one command to another as the input. Format: Command 1 | Command 2 example: [developer]/usr/xxxx/ytcclb> who | awk '{print $1 "\ t" $2}' xxxx ttyp0 xxxx ttyp1 xxxx ttyp2... xxxx ttyp55 [developer]/usr/xxxx/ytcclb> df-k | awk '{print $1}' | grep-v "Filesystem"/dev/root/dev/boot [development]/usr/xxxx/ytcclb> df-k | awk '{print $1}' | grep-v "Filesystem" | sed s'/\/dev \/// g'root boot [development]/usr/xxxx/ytcclb> tee command: one copy of the output is delivered to the standard output, and the other copy is copied to the corresponding file. Tee-a file-a: append to the end of the file. [Developer]/usr/xxxx/ytcclb> who | tee who. out saves the data found by the who command to the who. out file. File redirection: command> filename redirects the standard output to a new file. command> filename redirects the standard output to a file (append) command 1> fielname redirects the standard output to a file command> filename 2> & 1 redirects the standard output and standard error together to a file command 2> filename redirects the standard error command 2> filename in a file redirects the standard output to a file (append) command> filename 2> & 1 redirects the standard output and standard error together to a file (append) command <filename> filename2 uses the command file as the standard input, output command using the filename2 file as the standard <filename The ilename file is used as the standard input command <delimiter reads from the standard input, until the delimiter command <& m redirects the file descriptor m to the file descriptor m as the standard input command> & m redirects the standard output to the file descriptor m command <&-redirects the standard output of the disabled standard input to the file descriptor m. 1. append the output of many commands to a file ls-l | grep ^ d> files. out ls account *> files. out [development]/usr/xxxx/ytcclb> ls-l null.txt-rw-r -- 1 xxxx group 3 Nov 15 07 null.txt [development]/usr/xxxx/ytcclb> chmod u + x null.txt chmod: WARNING: cannot access + x: No such file or direct There is a space between ory (error 2) u and + x! [Development]/usr/xxxx/ytcclb> chmod u + x null.txt [development]/usr/xxxx/ytcclb> ls-l null.txt-rwxr -- r -- 1 xxxx group 3 Nov 15 16: 07 null.txt
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.