how to seperate a variable in 2 variables

Dear all,

i dont know how to split one variable value in 2 variable. please send me any example.

variable1= "abcde developer"

now i want to seperate the values and seperator is space.

var1="abcde developer"
echo "$var1" | read var2 var3
echo "$var2"
echo "$var3"

thanks alot for your quick response, but it is including ^M at the end and also entering a blank line.

plz have a look

for myvar1 in $(awk -F, '{print $1,$5}' $Filename $filen|tr "a-z" "A-Z" )
do
echo "$myvar1" | read var2 var3
sqlplus -s test/test@test @gur.sql $DefaultProduct $var2 $var3
done >>getdata.tmp

in above example, i have to give 3 parameters to gur.sql, i am reading a variable myvar1 from a file, this variable contains 2 values of $1,$5. now i am using your command but its not working. plz if possible then answer it ASAP.

thanks alot

If you get ^M and/or empty lines, the problem commes from your input datas and not from the read command.
You can modify your awk command to remove �M and empty lines :

for myvar1 in $(awk -F, 'NF {gsub(/\r/, ""); print $1,$5}' $Filename |tr "a-z" "A-Z" )

Another way :

awk -F, 'NF {gsub(/\r/, ""); print tolower($1),tolower($5)}' $Filename | \
while read var2 var3
do
   sqlplus -s test/test@test @gur.sql $DefaultProduct $var2 $var3
done >>getdata.tmp

Jean-Pierre.

read var2 var3 <<<$var1

And don't forget the ever venerable

set -- $var1  # populate $* from $var1, split on $IFS
var2=$1
var3=$2

Thanks alot brothers,
i have done with your help.

Regards,
Intikhab Alam
Certified ISMS 27001 Lead Auditor (Information Security Management System)
Certified ISO 9000:2000 Lead Auditor
Brainbench SCM, SQA, Testing & SEI CMMI Certified
CMA-CGM SYSTeMS
(A Joint Venture of CMA-CGM and IBM)