Linux shell input and output

Source: Internet
Author: User
Tags control characters echo command

Echo-echo command can display a line or variable of text, or enter a string into the file string-  E To resolve the escape character    "nimenhao\ Nasfdsaf"     printing occurs  line -N-Carriage does not wrap        in detail: Generally in the command line to print the string, the cursor will be displayed on the next line, but using the Echo-n parameter, You can make the printed text and the cursor on the same line

Read-The Readstatement reads the information from a line of text in the keyboard or file and assigns it to a variable -read var1 var2    ... If only one variable is specified, read will assign all input to the variable until the first file terminator or carriage return is encountered.
If multiple variables are given, they are assigned different variables in order. The shell will use a space as a delimiter between the variables -NOTE: When there is only one variable, all inputs are assigned to the variable, even if a space is added.

Cat-cat is a simple and versatile command that can be used to display file contents, create files, and use it to display control characters -cat [options] filename1 filename2-- " - v "     Display control characters -- note that when using the Cat command, he will not stop at the file page, he will display the entire file at once  if you want to display a page at a time, you can use the more command or pass the output of the cat command through a pipeline to another command with paging (more, less). --Example: Cat filename | more--cat command can display multiple files simultaneously    cat filename1 filename2

pipe (|) --You can pass the output of one command to another command through the pipeline to do the input.

Tee-theTee command outputs the result to the standard output, and the other copy is output to the corresponding file --tee-a-         A: Append-    a means overwrite -- This command is typically used after a pipeline (typically to see the output and save the file)

file Redirection--change the input source and output location of the program run--command >filename redirects the standard output to a new file--command >>filename redirects the standard output to a file (append)--command1>filename redirect standard output to a new file note "1>" This is the number 1, and the number 1 and ">" cannot have spaces between--command > FileName 2>$1 (number 1) redirect standard output and standard error to a file Note: for commands "2>$1", "2>&" can not be added to the middle of any space, but with the number 1 can be added space, or no space--command2>filename redirects a standard error to a file--command2>>filename redirects the standard output to a file (append)--command >> filename2>&1REDIRECT standard output and standard error to a file (append)--command < filename >The filename command commands the filename file as the standard input, with the filename2 file as the standard output--command <the filename command commands the filename file as the standard input--command <<The delimiter is read from the standard input until the delimiter delimiter is encountered--command <&m The file descriptor m as standard input--command >&m redirect the standard output to the file descriptor m--command <&-turn off standard input

exec- The first use: the EXEC command can be used in place of the current shell: in other words, if the shell is not started, any existing environment will be purged and a shell restarted-exec Command command command    usually refers to a shell script, exec executes a shell script, will replace the bash program with the current shell program, resulting in the current bash exit  - Second usage: When exec operates on a file descriptor, it will not overwrite your current shell at this time.

Linux shell input and output

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.