Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

related question



On Thu, Jan 15, 1998 at 10:28:37AM +0000, Andrew Main wrote:

> for ((i=0;i<=100;i++)); do
> 	echo $i
> done

	i've got a similar loop (just converted to this new for format, which 
i'm trying to get used to using), to set the values in an array:

while read line ; do	
   for ((i=1;i<=11;i++)) ; do 
      field[$i]=`echo $line | cut -d';' -f$i | tr -d '"'`
   done
done < in.file

	this should take a line of the format 

"foo1";"foo2";"foo3"; [...] ;"foo11"

	and stuff each foo# into the appropriate spot in the array named field.  
my question is, how do i then concatenate all of these values back into one 
line?  what i'm currently doing, since the max value for i is so small, is just 
	
echo 
"\"$field[1]\";\"$field[2]\";\"$field[3]\";\"$field[4]\";\"$field[5]\";\"$field[
6]\";\"$field[7]\";\"$field[8]\";\"$field[9]\";\"$field[10]\";\"$field[11]\""

pretty soon, however, i'm going to have to use this script on a larger set of 
data, with a lot more fields per line; i don't want to have to type out each 
item of the array individually.  i know there's an easier way to do it, but it's 
late, and my brain isn't working very well.

	any suggestions (other than using perl, which is what all of my 
coworkers say to do)?
	
	tia,
	sweth.


-- 
"Countin' on a remedy I've counted on before
Goin' with a cure that's never failed me
What you call the disease
I call the remedy"  -- The Mighty Mighty Bosstones



Messages sorted by: Reverse Date, Date, Thread, Author