Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > AWK....
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 31st October 18:10
External User
 
Posts: 1
Default AWK....



$2 contains "abc:def"
while [ 1]
do
count=0
status[$count]=`echo "$2" | awk -F: '{ print $count }'`

when we execute the above command status[1] should get "abc and
status[2] should get def...
but it does not work....can somebody advice.....

count=$((count+1));

---do soemthing.......

done
  Reply With Quote


 


2 31st October 18:10
ed morton
External User
 
Posts: 1
Default AWK....



This is the correct syntax for what you're trying to do:

status[$count]=`echo "$2" | awk -F: -v cnt="$count" '{ print $cnt }'`

See question 24 in the comp.unix.shell FAQ,
http://home.comcast.net/~j.p.h/cus-faq-2.html#24.

Having said that, the above script doesn't make sense because you're
setting count to zero every time round the loop and you don't need awk
to do what you want anyway. You should post a questioin to
comp.unix.shell asking for help on generally fixing the script.

Ed.
  Reply With Quote
3 10th November 03:12
loki harfagr
External User
 
Posts: 1
Default AWK....


Le Wed, 13 Sep 2006 07:06:59 -0500, Ed Morton a écrit*:


Yes, and now I just can't wait to see coming in comp.unix.shell
a post entitled "SHELL" ;D)
  Reply With Quote
Reply


Thread Tools
Display Modes




666