Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 11:18 on June 26, 2006


Variable Assignment Problem Solving

Procedure :
Echo ${sho} |grep 1, named a1=\$1
Echo ${sho} |grep 2, named a2=\$2
Echo ${sho} |grep 3, named a3=\$3
Echo ${sho} |grep 4, named a4=\$4
Echo ${sho} |grep 5, named a5=\$5
6, named a6=\$6 echo ${sho} |grep
Echo ${sho} |grep 7, named a7=\$7


If the input variables containing 1 sho, a1=$1.
If the input variables containing 2 sho, a2=$2
Renumbered.

If sho=347 operations,

Echo "\$a1=" $a1 "\$a2=" $a2 "\$a3=" $a3 "\$a4=" $a4 "\$a5=" $a5 "\$a6=" $a6 "\$a7=" $a7

$a1= $a2= $a3=$3 $a4=$4 $a5= $a6= $a7=$7

Was correct.


Question : it hopes to achieve recycling.

For i in 1 2 3 4 5 6 7
Do
Echo ${sho} |grep $i, named a${i}=\$${i}
Done


It is obviously not acceptable and tried echo ${sho} |grep $i, named eval a${i}=\$${i} too.


Solving Thank you.


Sorry, made a two times

Top about

Eval a$i=\\$\$i



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com