If there are fewer variable arguments than standard input fields then the leftover fields are assigned to the final variable. If there are fewer fields than variables then the remaining variables are set to empty strings.
The -r option causes the backslash character ``\'' to be interpreted as part of the input line. By default backslash is treated as a line continuation character.
Print input_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_filePrint out the user ID of each user in /etc/passwd:
IFS=":"while true do read -r uname passwd uid remainder || exit print "${uname}'s UID is $uid" done < /etc/passwd
read is implemented as a built-in command to the Bourne and Korn Shells only. It is not available in the C shell.
ISO/IEC DIS 99452:1992, Information technology Portable Operating System Interface (POSIX) Part 2: Shell and Utilities (IEEE Std 1003.21992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.