Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Aug 2000 09:36:17 -0700 (PDT)
From:      <keith@mail.telestream.com>
To:        J A Shamsi <jashamsi@yahoo.com>
Cc:        questions@FreeBSD.ORG
Subject:   Re: scripts
Message-ID:  <Pine.LNX.4.10.10008030916490.5551-100000@mail.telestream.com>
In-Reply-To: <20000803155918.1816.qmail@web4105.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Here's a fishing pole. You'll need to learn to fish though to be able to 
use it. You could do something like this. Assumes that you are giving the
file name on the command line hence the $1. If you need it to find it
automaticaly the man page for find will help you. This also assumes 5
fields. 

#!/usr/local/bin/bash

CUT=`cut -f 1,2,3,4,5 -d , $1
NAME=($CUT)

If you want to take the ',' out of the delimited portion you can do this.

CUT=`cut -f 1,2,3,4,5 -d : $1|sed 's/:/ /g'`
NAME=($CUT)

That will put all the , delimited fields into an array called NAME which
you can access by the array index. Read up on how to access those feilds.
Here's the BASH reference manual
http://www.gnu.org/manual/bash-2.02/html_mono/bashref.html#SEC115


:-)   


=================================
Keith W.
At the helm <for better or worse>

My non work related site
www.cydonia.net
=================================


On Thu, 3 Aug 2000, J A Shamsi wrote:

> HI
> I am new to shell scripting, 
> I would like to create a script in bash shell.
> that would do the following
> 
> 1) find out the latest file ( text file)in a directory
> ( there are bunch of files in a dir)
> 
> 2)open that file (text file) and parse the
> values seperated by comma and store them in variables.
> 
> just wondering is there any howto or documenation
> available on the web, or if anyone has any idea...
> 
> thanks
> 
> jas
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Kick off your party with Yahoo! Invites.
> http://invites.yahoo.com/
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message
> 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.10.10008030916490.5551-100000>