Phil, Thank you for your reply. However, I don't know if I could use the
tr command because I'm trying to delete null charachters form a VARIABLE,
not a text file. Can the same command be used? If not, is there another
command that can be?
Anyone can answer that!!!!! Thanks..............Lucy
---------------------- Forwarded by Lucy Premus/Bsg/MetLife/US on 01/19/99
01:34 PM ---------------------------
"Gregory, Phil" <phil.gregory@exchange.meb.co.uk> on 01/19/99 11:07:25 AM
To: Lucy Premus/Bsg/MetLife/US
cc:
Subject: FW: assigning variables in a script
Hi again Lucy,
You'll need a $ in front of the open bracket on the first_line and
second_line lines!
Phil.
Data Network Services
Midlands Electricity
Kingswinford.
phil.gregory@meb.co.uk Tel.01384.296.191 [x3511] fax.01384.405155
> -----Original Message-----
> From: Gregory, Phil
> Sent: Tuesday, January 19, 1999 3:53 PM
> To: 'Discussion of IBM NetView and POLYCENTER Manager on NetView'
> Subject: RE: assigning variables in a script
>
> Hi Lucy,
>
> You can remove all multiple occurences of a character in a text file
> (including control characters) by using the 'tr' command.
> Try:-
> tr -s ' ' < textfile > newfile #would remove multiple occuring
> spaces
>
> Then to assign variables to each word in a line, try using the 'cut'
> command
>
> cat newfile |while read text_line
> do
> first_word=(echo $text_line |cut -d" " -f 1)
> second_word=(echo $text_line |cut -d" " -f 2)
> ....
> ......
> ....
> done
>
> Have a look at the man pages for 'tr' and 'cut' for more info.
>
> Have fun,
>
> Phil Gregory
>
> Data Network Services
> Midlands Electricity
> Kingswinford.
>
> phil.gregory@meb.co.uk Tel.01384.296.191 [x3511] fax.01384.405155
>
>
> -----Original Message-----
> From: Lucy Premus [SMTP:lpremus@METLIFE.COM]
> Sent: Tuesday, January 19, 1999 3:30 PM
> To: NV-L@UCSBVM.ucsb.edu
> Subject: assigning variables in a script
>
> Okay. I have another question regarding variables and scripts. But
> before
> I ask this one, just wondering if anyone knows the answer to my previous
> question?. How do you remove preceding spaces in a variable? Meaning if
> I
> have a variable that looks like this
> ' TRUE', but all I really need is just the word
> TRUE. How do I get rid of the spaces before the word?
>
> My other question is if my script is reading a text file and processing
> each line, how do I parse out each word on that line and assign it to a
> variable? For example, the line looks like this: 'resourcename Jan 15
> 10:00:00 EST 1999' and I just want to capture 'resourcename' and assign
it
> to one variable and capture '10:00:00' and assign it to another
variable.
>
> BTW....In case anyone is wondering, I do have a Korn Shell programming
> book, but I can't seem to find this information in there. I'm sure its
> there, in some form, but is it english? Thanks for all the
> help..................Lucy
>
> ================================================================
> This incoming e-mail (and any attachments) has been checked at MEB
> (UK 01384 296191), and has been found to be clean from any
> virus infection (using Dr Solomon's v7.91).
>
> If you have any queries about viruses, please contact PC Tech
> Support (09 3521) or about the external e-mail system, contact
> David Perry (09 3673).
>
> ================================================================
================================================================
This outgoing e-mail (and any attachments) has been checked
(using Dr Solomon's v7.91) at MEB (UK 01384 296191) before
despatch, and has been found to be clean from any virus infection.
If you have any queries about viruses, please contact PC Tech
Support (09 3521) or about the external e-mail system, contact
David Perry (09 3673).
================================================================
|