Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The read command with -r; any good examples?

Status
Not open for further replies.

goldenradium2001

Technical User
Mar 22, 2002
91
US
I'm trying to learn Korn shell scripting and I've got five different books quoting the man page for the read command using the -r option. What's the point in using the -r option? Can anyone give me a good example?

THanks in advance.
 
hi

have a look at this ,

if you have a file called AAA
in it it has

/aaa /bbb
\ccc \ddd

note forward slash for aaa +bbb and back slash for
ccc+ddd


if you do this :-

while read aa bb
do
printf "%s %s \n" "$aa" "$bb"
done < /tmp/AAA


you'll get following output
/bbb /aaa
ddd ccc

note no black slashes displayed

with the -r option from read used you'll get the backslash displayed

/bbb /aaa
\ddd \ccc

To use this , may be the ourput required from the input file would be a backslash , depending on how ou want your output displayed .

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top