zsh-users
 help / color / mirror / code / Atom feed
From: Sweth Chandramouli <sweth@astaroth.nit.gwu.edu>
To: zsh-users@math.gatech.edu
Subject: related question
Date: Wed, 21 Jan 1998 22:54:25 -0500	[thread overview]
Message-ID: <19980121225425.23392@astaroth.nit.gwu.edu> (raw)
In-Reply-To: <199801151028.KAA21473@taos.demon.co.uk>; from Andrew Main on Thu, Jan 15, 1998 at 10:28:37AM +0000

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


  parent reply	other threads:[~1998-01-22  4:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-15  0:12 I've forgotten again how to do this --> 0-100 Timothy J Luoma
1998-01-15  0:46 ` Danek Duvall
1998-01-15  1:03   ` Mirar
1998-01-15 10:28 ` Andrew Main
1998-01-15 15:01   ` Geoff Wing
1998-01-15 17:39   ` Brandon C. George
1998-01-15 17:51     ` Andrew Main
1998-01-15 20:32   ` Sweth Chandramouli
1998-01-15 22:59     ` Geoff Wing
1998-01-21 16:26       ` loops and all that Sven Guckes
1998-01-22  3:54   ` Sweth Chandramouli [this message]
1998-01-22  9:24     ` related question Bernd Eggink
1998-01-22 13:00     ` Mirar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19980121225425.23392@astaroth.nit.gwu.edu \
    --to=sweth@astaroth.nit.gwu.edu \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).