Introduction to read commands in LINUX

Source: Internet
Author: User
Read [-ers] [-ufd] [-ttimeout] [-aaname] [-pprompt] [-nnchars] [-ddelim] [name...] Onelineisreadfromthestandardinput, bytes-u

Read [-ers] [-u fd] [-t timeout] [-a aname] [-p prompt] [-nnchars] [-d delim] [name...]

One line is read from the standard input, or from the filedescriptor fd supplied as an argument to the-u option, and thefirst word is assigned to the first name, the second word to thesecond name, and so on, with leftover words and their interveningseparators assigned to the last name. if there are fewer words readfrom the input stream than names, the remaining names are assignedempty values. the characters in IFS are used to split the line into words. the backslash character (\) may be used to remove anyspecial meaning for the next character read and for linecontinuation. options, if supplied, have the followingmeanings:

-A aname

The words are assigned to sequential indices of the arrayvariable aname, starting at 0. aname is unset before any new valuesare assigned. Other name arguments are ignored.

-D delim

The first character of delim is used to terminate the inputline, rather than newline.

-E If the standard input is coming from a terminal, readline (see READLINE abve) is used to obtain the line.

-N nchars

Read returns after reading nchars characters rather thanwaiting for a complete line of input.

-P prompt

Display prompt on standard error, without a trailing newline, before attempting to read any input. The prompt is displayed onlyif input is coming from a terminal.

-R Backslash does not act as an escape character. Thebackslash is considered to be part of the line. In particle, abackslash-newline pair may not be used as a line continuation.

-S Silent mode. If input is coming from a terminal, charactersare not echoed.

-T timeout

Cause read to time out and return failure if a complete lineof input is not read within timeout seconds. This option has noeffect if read is not reading input from the terminal or apipe.

-U fd Read input from file descriptor fd.

If no names are supplied, the line read is assigned to theariable REPLY. the return code is zero, unless end-of-file isncountered, read times out, or an invalid file descriptor issupplied as the argument to-u.
========================================================== ========================================================== ========

-P prompts the user to enter

-S can hide user input

-D can specify a series of letters. if any of the letters appears during input, it is aborted.

-T: specifies the timeout value.

-R can retain escape characters

-U can be read from the file. However, this file refers to the file descriptor rather than the file name.

-N: specifies the number of bytes to be read, and stops immediately after reading.

========================================================== ========================================================== =====

In shell, "press any key to continue ..."

Read-n1-s-p "press any key to continue ..."

========================================================== ======================================

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.