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

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

Contents


read(1)								       read(1)


NAME    [Toc]    [Back]

     read - read a line	from standard input

SYNOPSIS    [Toc]    [Back]

     read [-r] var...

DESCRIPTION    [Toc]    [Back]

     The read utility will read	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	will prompt for	a continuation line when:

	  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 will be split into fields	as in the shell; the first field will
     be	assigned to the	first variable var, the	second field to	the second
     variable var, and so on. If there are fewer var operands specified	than
     there are fields, the leftover fields and their intervening separators
     will be assigned to the last var. If there	are fewer fields than vars,
     the remaining vars	will be	set to empty strings.

     The setting of variables specified	by the var operands will affect	the
     current shell execution environment; see Shell Execution Environment.  If
     it	is called in a subshell	or separate utility execution environment,
     such as one of the	following:


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

     it	will not affect	the shell variables in the caller's environment.

OPTIONS    [Toc]    [Back]

     The read utility supports the XBD specification, Utility Syntax
     Guidelines.

     The following option is supported:

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

OPERANDS    [Toc]    [Back]

     The following operands are	supported:






									Page 1






read(1)								       read(1)



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

STDIN    [Toc]    [Back]

     The standard input	must be	a text file.

ENVIRONMENT VARIABLES    [Toc]    [Back]

     The following environment variables affect	the execution of read:

     IFS   Determine the internal field	separators used	to delimit fields.

     PS2   Provide 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.

EXIT STATUS    [Toc]    [Back]

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

APPLICATION USAGE    [Toc]    [Back]

     The read utility has historically been a shell built-in.

     The -r option is included to enable read to subsume the purpose of	the
     line utility, which has been marked LEGACY.

     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.

EXAMPLES    [Toc]    [Back]

     The following command:


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

     prints a file with	the first field	of each	line moved to the end of the
     line.

SEE ALSO    [Toc]    [Back]

      
      
     sh(1).


									PPPPaaaaggggeeee 2222
[ Back ]
 Similar pages
Name OS Title
tee Linux read from standard input and write to standard output and files
read Tru64 Reads a line from standard input
line Tru64 Reads one line from standard input
getwchar Linux read a wide character from standard input
line HP-UX read one line from user input
encrypt OpenBSD encrypt passwords from the command line or standard input
makekey OpenBSD encrypt passwords from the command line or standard input
line IRIX read one line
bad144 OpenBSD read/write DEC standard 144 bad sector information
gets IRIX Read a line from a file
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service