Bobby,
I use rexx all the time under linux. Why don't you pipe you grep to a temp
file then read that file into a stem var, which you can then parse to your
hearts content?

Richard

- -
Richard J Moore - FIET, FBCS, CEng, CITP
IBM z/VM CP Endicott, Z Optimizer Manchester, Linux Technology Centre
Member of the IBM Academy of Technology
http://www-03.ibm.com/ibm/academy/index.html

MOBEX: 37264807; Mobile (+44) (0)7739-875237
Office: (+44) (0)1962-817072


|------------>
| From:      |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |"Bauer, Bobby (NIH/CIT) [E]" <[email protected]>                          
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |[email protected]                                                      
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |23/12/2010 16:59                                                             
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Re: A little more script help                                                
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Sent by:   |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Linux on 390 Port <[email protected]>                                  
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|





Thanks for the advice. As far as using Perl or Python, I'd rather use Rexx
but I'm trying to become a Linux guy instead of am MVS guy and I've got to
start somewhere. Yes I know Rexx is available on Linux but for now, I
choose bash for good or bad. Guess I'm familiar with arrays (or stacks as
they are called in Rexx) so that's what I'll use for now.
Aha!, it was my echo command that was wrong.

Bobby Bauer
Center for Information Technology
National Institutes of Health
Bethesda, MD 20892-5628
301-594-7474



-----Original Message-----
From: Philip Rowlands [mailto:[email protected]]
Sent: Thursday, December 23, 2010 11:51 AM
To: [email protected]
Subject: Re: A little more script help

On 23/12/2010 16:28, Bauer, Bobby (NIH/CIT) [E] wrote:
> OK, I'm going to forgo Rexx and learn bash script!
> I want to input a file into an array. For instance I want the variable
xyz to have the contents of /tmp/test. /tmp/test looks like:
>
> 08:50:01 AM       all      3.48      0.00      0.18      0.15      0.19
95.99
> 09:00:02 AM       all      3.51      0.00      0.19      0.15      0.11
96.05
>
>
> I tried:
>
> xyz=(`cat /tmp/test`)
>    and
> xyz=('grep all /tmp/test`)
>
> but I only get the first word, the 08:50:01. How can I get everything?

This doesn't quite do what you think. How are you referencing the array?

$ xyz=(`cat /tmp/test`)

$ echo ${xyz[*]}
08:50:01 AM all 3.48 0.00 0.18 0.15 0.19 95.99 09:00:02 AM all 3.51 0.00
0.19 0.15 0.11 96.05

If you just ask for $xyz you get the first element of the array. Another
problem is that bash arrays are one-dimensional; you can simulate
multidimensional arrays, but why torture yourself?

http://tldp.org/LDP/abs/html/arrays.html

Perl or Python would be better suited to script processing of text files
once the requirements become anything more than simple. If you're really
keen on using bash, I'd still suggest using the "read" builtin and shell
arithmetic before resorting to arrays. Consider the memory requirements
when the input isn't 2 lines, but 2 million.


Cheers,
Phil

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or
visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For more information on Linux on System z, visit
http://wiki.linuxvm.org/

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or
visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For more information on Linux on System z, visit
http://wiki.linuxvm.org/

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For more information on Linux on System z, visit
http://wiki.linuxvm.org/

Reply via email to