how to use builtins?

Hi everyone,

First of all sorry for the newbish question. Basically, I need the syntax for the 'read' command. If I read the man page for read, i get the page for builtins but this does not have the syntax.

As you might imagine, googling for anything related to a command called 'read' gives results that are .... ironic, i guess. Lots of stuff about how i should read manual pages ;) "I want to!" I tell it but that's no help.

So how might I figure this out short of examining source code?

thanks,
K. Plankton
 
You need look at the manpage of your shell, which is sh(1) or tcsh(1).

For read you're probably talking about a shell script and thus sh.

The sh manpage is very long, but search it for "Built-in Commands", this gives you a list of all built-ins with explanation

Code:
     read [-p prompt] [-t timeout] [-er] variable ...
             The prompt is printed if the -p option is specified and the stan‐
             dard input is a terminal.  Then a line is read from the standard
             input.  The trailing newline is deleted from the line and the
             line is split as described in the section on White Space
             Splitting (Field Splitting) above, and the pieces are assigned to
             the variables in order.  If there are more pieces than variables,
             the remaining pieces (along with the characters in IFS that sepa‐
             rated them) are assigned to the last variable.  If there are more
             variables than pieces, the remaining variables are assigned the
             null string.

             Backslashes are treated specially, unless the -r option is speci‐
             fied.  If a backslash is followed by a newline, the backslash and
             the newline will be deleted.  If a backslash is followed by any
             other character, the backslash will be deleted and the following
             character will be treated as though it were not in IFS, even if
             it is.

             If the -t option is specified and the timeout elapses before a
             complete line of input is supplied, the read command will return
             an exit status of 1 without assigning any values.  The timeout
             value may optionally be followed by one of ‘s’, ‘m’ or ‘h’ to
             explicitly specify seconds, minutes or hours.  If none is sup‐
             plied, ‘s’ is assumed.

             The -e option exists only for backward compatibility with older
             scripts.
 
Back
Top