How to get READ command working in LINUX. [message #526533] |
Tue, 11 October 2011 08:51 |
shamsh_pervaiz
Messages: 22 Registered: September 2005 Location: bangalore
|
Junior Member |
|
|
Hello experts,
I 'm new to scripting.
I was trying one script which has to be common and be executed both on AIX and LINUX.
I have the input to be split into 2 variables, so I tried READ command in AIX and it is working fine as below:
AIX
---
>echo "ABC DEF" | read X Y; echo "X value="$X; echo "Y value="$Y;
X value=ABC
Y value=DEF
Where as when I try the same on LINUX, method same as AIX does not work, but works with "WHILE READ".:
LINUX
-----
>$ echo "ABC DEF" | read X Y; echo "X value="$X; echo "Y value="$Y;
X value=
Y value=
>$ echo "ABC DEF" | while read X Y; do echo "X value="$X; echo "Y value="$Y;done
X value=ABC
Y value=DEF
CAN ANY ONE HELP ME IN RESOLVING THE ISSUE ON LINUX. I CAN NOT USE "WHILE READ" AS THIS INCLUDES A LOT OF OTHER CODE WHICH CAN NOT BE PUT IN BETWEEN "DO" AND "DONE".
WHAT IS THE REASON "READ" COMMAND ON LINUX DOES NOT WORK IN SAME PASSION AS AIX.
PLEASE HELP.
Thanks in advance,
Shamsh
|
|
|
|