February 2001
Beginner to intermediate
448 pages
9h 2m
English
Official Description
Reads a line from standard input.
Syntax
read [-r] var...
Options
-r requests that the shell not treat a backslash character in any special way.
Oddities
The -r option enables the read command to replace the line command.
Example
$ ls -li b* 4054 -r-x-w-r-x 1 obrien obrien 47 Nov 26 12:19 buzz 4039 -rwxrwxr-- 1 obrien obrien 90 Nov 26 12:45 buzz1 4055 -rwxrwxr-- 1 obrien obrien 152 Nov 26 12:48 buzz2 4057 -rwxrwxr-- 1 obrien obrien 116 Nov 26 14:07 buzz3 4058 -rwxrwxr-- 1 obrien obrien 165 Nov 26 14:08 buzz4 $ $ ls -li b* | while read -r x y # Read first field int x, # rest of line into y > do > printf "%s %s\n" "$y" "$x" # Print y, then x > done # Inode number field is now the last field -r-x-w-r-x 1 obrien obrien ...
Read now
Unlock full access