aix中read命令的用法

$ cat readtxt
ni hao ma
he ha a

$ vi readtest
"readtest" 5 lines, 89 characters
#!/bin/ksh
while read xx yy zz
do
printf "%s %s %sn" $xx $yy $zz
done

$ readtest
ni hao ma
he ha a

--------------------------------------------------------------------------

$ vi readtest
"readtest" 5 lines, 82 characters
#!/bin/ksh
while read xx yy
do
printf "%s %s " $yy $xx
done

$ readtest
hao ma ni ha a he

------------------------------------------------------------------------

$ vi readtest
"readtest" 5 lines, 81 characters
#!/bin/ksh
while read xx yy
do
printf "%s %sn" $yy $xx
done

$ readtest
hao ma
ni
ha a
he

变量一一对应,若给予的变量个数没有文件中域的个数多,则将最后的几个域全赋给最后一个变量.

--------------------------------------------------------------------------

$ read word1?"please enter:" word2
please enter:hello world
You have mail in /usr/spool/mail/oracle
$ echo $word1
hello
$ echo $word2
world

------------------------------------------------------------------------

$ (read; print "hello $REPLY")
word(我输入的)
hello word(打印输出的)

[@more@]
请使用浏览器的分享功能分享到微信等