*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> read (1)              
Title
Content
Arch
Section
 

read(1)

Contents


NAME    [Toc]    [Back]

       read - Reads a line from standard input

SYNOPSIS    [Toc]    [Back]

       read [-r] var...

STANDARDS    [Toc]    [Back]

       Interfaces  documented  on  this reference page conform to
       industry standards as follows:

       read:  XCU5.0

       Refer to the standards(5) reference page for more information
 about industry standards and associated tags.

OPTIONS    [Toc]    [Back]

       Do  not  treat  a  backslash character in any special way.
       Consider each backslash to be part of the input line.

                                     Note

              The -r option is included to enable read to subsume
              the purpose of the obsolete line utility.

OPERANDS    [Toc]    [Back]

       The name of an existing or non-existing shell variable.

DESCRIPTION    [Toc]    [Back]

       The  read utility reads a single line from standard input.

       By default, unless the -r option is  specified,  backslash
       (\)  acts  as an escape character.  If standard input is a
       terminal device and the  invoking  shell  is  interactive,
       read  prompts  for  a  continuation  line in the following
       cases: The shell reads an input line ending with  a  backslash,
 unless the -r option is specified.  A here-document
       is not terminated after a newline character is entered.

       The line is split into fields as in  the  shell  (see  the
       sh(1)  reference page); the first field is assigned to the
       first variable var, the second field to the  second  variable
 var, and so forth.  If there are fewer var parameters
       specified than there are fields, the leftover  fields  and
       their intervening separators are assigned to the last var.
       If there are fewer fields than vars,  the  remaining  vars
       are set to empty strings.

       The  setting  of variables specified by the var parameters
       affects the current shell execution environment.  If  read
       is  called  in  a  subshell  or separate utility execution
       environment, such as one of the  following,  it  does  not
       affect the shell variables in the caller's environment:

       (read foo) nohup read ...  find . -exec read ... \;






NOTES    [Toc]    [Back]

       The  -r  option  is included to enable read to subsume the
       purpose of the obsolete line utility.

RESTRICTIONS    [Toc]    [Back]

       The results are undefined if an  end-of-file  is  detected
       following  a backslash at the end of a line when -r is not
       specified.

EXIT STATUS    [Toc]    [Back]

       The following exit values are returned: Successful completion.
  End-of-file was detected or an error occurred.

EXAMPLES    [Toc]    [Back]

       The  following  command prints a file with the first field
       of each line moved to the end of the line:

       while read -r xx yy do
            printf "%s %s\n" "$yy" "$xx" done < input_file

ENVIRONMENT VARIABLES    [Toc]    [Back]

       The following environment variables affect  the  execution
       of  read: Determines the internal field separators used to
       delimit fields.  Provides a default value for the internationalization
  variables  that are unset or null.  If LANG
       is unset or null, the corresponding value from the default
       locale  is used.  If any of the internationalization variables
 contain an invalid setting, the utility  behaves  as
       if  none  of  the variables had been defined.  If set to a
       non-empty string value, overrides the values  of  all  the
       other   internationalization  variables.   Determines  the
       locale for the interpretation of  sequences  of  bytes  of
       text  data  as  characters  (for  example,  single-byte as
       opposed to multibyte characters in arguments).  Determines
       the locale used to affect the format and contents of diagnostic
 messages written to standard error.  Determines the
       location  of  message  catalogues  for  the  processing of
       LC_MESSAGES.  Provides the prompt string that an  interactive
 shell will write to standard error when a line ending
       with a backslash is read and the -r option was not  specified,
 or if a here-document is not terminated after a newline
 character is entered.

SEE ALSO    [Toc]    [Back]

      
      
       Commands:  line(1)

       Functions:  fread(3)

       Standards:  standards(5)



                                                          read(1)
[ Back ]
 Similar pages
Name OS Title
line Tru64 Reads one line from standard input
read IRIX read a line from standard input
read HP-UX read a line from standard input
makekey OpenBSD encrypt passwords from the command line or standard input
encrypt OpenBSD encrypt passwords from the command line or standard input
tee Linux read from standard input and write to standard output and files
ldterm HP-UX standard STREAMS terminal line discipline module
stdio IRIX standard buffered input/output package
stdio Linux standard input/output library functions
stdio FreeBSD standard input/output library functions
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service