[NTLUG:Discuss] A quick script anyone?
Scott Blaydes
sblaydes at netteksolutions.com
Thu Jul 31 11:06:05 CDT 2008
I would use cut to get the parts you need.
This would use the comma as the delimiter and get your the 10.
cut -f1 -d"," filename
This would use the double-quote as the delimiter and get you the US.
cut -f2 -d \" filename
This would use the double-quote as the delimiter and get you the United
States of America.
cut -f4 -d \" filename
You can then assign the returned values to your variables such as
ROW1=`cut -f2 -d \" filename`
IF I am wrong on any of this feel free to correct me.
Thank you,
Scott Blaydes
Daniel Hauck wrote:
> I know there are several very clever script writers here. You guys even
> seem to "think" in terms of scripting. I'm learning little by little
> all the great techniques you guys have shared in the past, but here's
> the present challenge:
>
> Parsing a CSV file and generating some output.
>
> I have a list where the first field is a number and the next two are
> text fields. A line would look like this:
>
> 10, "US", "United States of America"
>
> I just need to be able to parse this line to fill some variables. The
> output part I have down pretty well and will be able to transform this
> file (once I get the line parsing part down) into the output desired.
>
> It might be helpful to know that I will need to discard the quote
> characters and just need the text within.
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
More information about the Discuss
mailing list