The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 06-15-2009
Anteus Anteus is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 54
Quote:
Originally Posted by rakeshawasthi View Post
You can not do like this... $ should not come on the left side.
This will work...

Code:
Sam=`echo $line |awk -F" " {print $5}' |awk -F":" '{print $2}'`


-----------

Hi thanks.. the code you gave worked.

but further while accessing the array Sam. i am having some issues.

1: When i echo ${Sam[$2]} rather than giving the 2nd element it prints all of them

2: for (( i = 0 ; i < ${#Sam[@]} ; i++ ))
do
echo ${Sam[$i]}
done
its throwing an error
Test[16]: syntax error at line 17 : `((' unexpected

can you please tell how to go about accessing the array..