Text-only Table of Contents (frame/ no frame)
(15) Input and output Previous Top Next

Input and Output

Shell scripts can generate output directly or read input into variables using the following commands:

Script output

echo
Print arguments, separated by spaces, and terminated by a newline, to stdout. Use quotes to preserve spacing. Echo also understands C-like escape conventions. More detail
-n
suppress newline
print (ksh internal)
Print arguments, separated by spaces, and terminated by a newline, to stdout. Print observes the same escape conventions as echo.
-n
suppress newline
-r
raw mode - ignore \-escape conventions
-R
raw mode - ignore \-escape conventions and -options except -n.

Script input

read var1 var2 rest
read a line from stdin, parsing by $IFS, and placing the words into the named variables. Any left over words all go into the last variable. A '\' as the last character on a line removes significance of the newline, and input continues with the following line.
-r
raw mode - ignore \-escape conventions

Example: ex4a display, text


Previous Top Next


stdio.src  last modified Jun 9, 2006 Introduction Table of Contents
(frame/no frame)
Printable
(single file)
© Dartmouth College