Re: [CentOS] [OT] Bash help

2017-10-27 Thread Walter H.
On 25.10.2017 18:47, Warren Young wrote: You’re making things hard on yourself by insisting on Bash, by the way. This solution is better expressed in Perl, Python, Ruby, Lua, JavaScript…probably dozens of languages. or just awk ... ___ CentOS

Re: [CentOS] [OT] Bash help

2017-10-27 Thread Warren Young
On Oct 26, 2017, at 10:37 AM, Gordon Messmer wrote: > > On Wed, Oct 25, 2017 at 9:47 AM, Warren Young wrote: >> >> CentOS 5 is definitely out, as that ships Bash 3, which lacks this feature. > > Nonsense. Every POSIX shell has an associative

Re: [CentOS] [OT] Bash help

2017-10-27 Thread Proxy
This thread started as "I'm not sure if this is offtopic" and it ended as such a great and fun to read discussion. Thank you all for these great script examples. I really enjoyed reading it. On 2017-Oct-25 17:10, m.r...@5-cent.us wrote: > Tony Mountifield wrote: > > In article > >

Re: [CentOS] [OT] Bash help

2017-10-26 Thread Gordon Messmer
On Wed, Oct 25, 2017 at 9:47 AM, Warren Young wrote: > > This screams out for associative arrays. (Also called hashes, dictionaries, > maps, etc.) > > That does limit you to CentOS 7+, or maybe 6+, as I recall. CentOS 5 is > definitely out, as that ships Bash 3, which

Re: [CentOS] [OT] Bash help

2017-10-26 Thread Andrew Holway
> > You’re making things hard on yourself by insisting on Bash, by the way. I'd always assumed that shell scripting was a kind of sado masochistic medium allowing people who don't get out much to inflict horrible torture on each other. It certainly causes me great pain every time I try and read

Re: [CentOS] [OT] Bash help

2017-10-25 Thread m . roth
Tony Mountifield wrote: > In article > , > wrote: >> Warren Young wrote: >> > On Oct 25, 2017, at 10:02 AM, Mark Haney >> wrote: >> >> >> >> I have a file with two columns 'email' and

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Jon LaBadie
On Wed, Oct 25, 2017 at 10:47:12AM -0600, Warren Young wrote: > On Oct 25, 2017, at 10:02 AM, Mark Haney wrote: > > > > I have a file with two columns 'email' and 'total' like this: > > > > m...@example.com 20 > > m...@example.com 40 > > y...@domain.com 100 > >

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Chris Adams
Once upon a time, Warren Young said: > I was trying to think of which languages I know well which require even more > difficult solutions than the Bash 4 one. It’s a pretty short list: assembly, > C, and MS-DOS batch files. By “C” I’m including anything of its era and >

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Bowie Bailey
On 10/25/2017 3:34 PM, Warren Young wrote: On Oct 25, 2017, at 11:28 AM, Mark Haney wrote: An associative array was the first thing I thought of, then realized BASH doesn't do those. But it does: in Bash 4, only. If you mean you must still use Bash 3 in places, then

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Warren Young
On Oct 25, 2017, at 11:28 AM, Mark Haney wrote: > > An associative array was the first thing I thought of, then realized BASH > doesn't do those. But it does: in Bash 4, only. If you mean you must still use Bash 3 in places, then yeah, you’ve got a problem… one

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Tony Mountifield
In article , wrote: > Warren Young wrote: > > On Oct 25, 2017, at 10:02 AM, Mark Haney wrote: > >> > >> I have a file with two columns 'email' and 'total' like this: > >> > >>

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Robert Arkiletian
On Wed, Oct 25, 2017 at 12:08 PM, Robert Arkiletian wrote: > On Wed, Oct 25, 2017 at 9:59 AM, Robert Arkiletian wrote: >> On Wed, Oct 25, 2017 at 9:41 AM, Mark Haney wrote: >>> On 10/25/2017 12:33 PM, Robert Arkiletian wrote:

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Robert Arkiletian
On Wed, Oct 25, 2017 at 9:59 AM, Robert Arkiletian wrote: > On Wed, Oct 25, 2017 at 9:41 AM, Mark Haney wrote: >> On 10/25/2017 12:33 PM, Robert Arkiletian wrote: >>> >>> here is a python solution >>> #!/usr/bin/python >>> #python 2 (did not check if it

Re: [CentOS] [OT] Bash help

2017-10-25 Thread m . roth
Jason Welsh wrote: > hrm.. seems like you were missing a } > > sort file | awk '{array[$1] += $2;} END { for (i in array) {print i "\t" > array[i];}}' > Oops. Well, it's not vi, it's webmail, so I couldn't check... Thanks. mark > > regards, > > Jason > > > > On 10/25/2017 01:24 PM,

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Jason Welsh
hrm.. seems like you were missing a } sort file | awk '{array[$1] += $2;} END { for (i in array) {print i "\t" array[i];}}' regards, Jason On 10/25/2017 01:24 PM, m.r...@5-cent.us wrote: Warren Young wrote: On Oct 25, 2017, at 10:02 AM, Mark Haney wrote: I

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Leroy Tennison
Not enough experience with the mainframe: I meant WinDoze. - Original Message - From: "m roth" <m.r...@5-cent.us> To: "centos" <centos@centos.org> Sent: Wednesday, October 25, 2017 1:02:54 PM Subject: Re: [CentOS] [OT] Bash help Leroy Tennison wrote: >

Re: [CentOS] [OT] Bash help

2017-10-25 Thread m . roth
on an IBM mainframe, or...? mark "been around the block" > - Original Message - > From: "m roth" <m.r...@5-cent.us> > To: "centos" <centos@centos.org> > Sent: Wednesday, October 25, 2017 12:27:28 PM > Subject: Re: [CentOS] [

Re: [CentOS] [OT] Bash help

2017-10-25 Thread m . roth
Mark Haney wrote: > On 10/25/2017 01:24 PM, m.r...@5-cent.us wrote: >>> >>> This screams out for associative arrays. (Also called hashes, >>> dictionaries, maps, etc.) >>> >>> That does limit you to CentOS 7+, or maybe 6+, as I recall. CentOS 5 >>> is definitely out, as that ships Bash 3, which

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Mark Haney
On 10/25/2017 01:24 PM, m.r...@5-cent.us wrote: This screams out for associative arrays. (Also called hashes, dictionaries, maps, etc.) That does limit you to CentOS 7+, or maybe 6+, as I recall. CentOS 5 is definitely out, as that ships Bash 3, which lacks this feature. Associative

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Leroy Tennison
os" <centos@centos.org> Sent: Wednesday, October 25, 2017 12:27:28 PM Subject: Re: [CentOS] [OT] Bash help Warren Young wrote: > On Oct 25, 2017, at 11:00 AM, Leroy Tennison <le...@datavoiceint.com> > wrote: >> >> Although "not my question", thanks, I le

Re: [CentOS] [OT] Bash help

2017-10-25 Thread m . roth
Warren Young wrote: > On Oct 25, 2017, at 11:00 AM, Leroy Tennison > wrote: >> >> Although "not my question", thanks, I learned a lot about array >> processing from your example. > > Yeah, it’s amazing how many obscure corners of the Bash language must be > tapped to solve

Re: [CentOS] [OT] Bash help

2017-10-25 Thread m . roth
Warren Young wrote: > On Oct 25, 2017, at 10:02 AM, Mark Haney wrote: >> >> I have a file with two columns 'email' and 'total' like this: >> >> m...@example.com 20 >> m...@example.com 40 >> y...@domain.com 100 >> y...@domain.com 30 >> >> I need to get the total number of

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Mark Haney
On 10/25/2017 12:47 PM, Warren Young wrote: You’re making things hard on yourself by insisting on Bash, by the way. This solution is better expressed in Perl, Python, Ruby, Lua, JavaScript…probably dozens of languages. Yeah, you're right, I am. An associative array was the first thing I

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Warren Young
On Oct 25, 2017, at 11:00 AM, Leroy Tennison wrote: > > Although "not my question", thanks, I learned a lot about array processing > from your example. Yeah, it’s amazing how many obscure corners of the Bash language must be tapped to solve such a simple problem. I

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Leroy Tennison
Although "not my question", thanks, I learned a lot about array processing from your example. - Original Message - From: "warren" <war...@etr-usa.com> To: "centos" <centos@centos.org> Sent: Wednesday, October 25, 2017 11:47:12 AM Subject: Re

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Robert Arkiletian
On Wed, Oct 25, 2017 at 9:41 AM, Mark Haney wrote: > On 10/25/2017 12:33 PM, Robert Arkiletian wrote: >> >> here is a python solution >> #!/usr/bin/python >> #python 2 (did not check if it works) >> f=open('yourfilename') >> D={} >> for line in f: >> email,num =

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Warren Young
On Oct 25, 2017, at 10:02 AM, Mark Haney wrote: > > I have a file with two columns 'email' and 'total' like this: > > m...@example.com 20 > m...@example.com 40 > y...@domain.com 100 > y...@domain.com 30 > > I need to get the total number of messages for each email

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Bowie Bailey
On 10/25/2017 12:41 PM, Mark Haney wrote: On 10/25/2017 12:33 PM, Robert Arkiletian wrote: here is a python solution #!/usr/bin/python #python 2 (did not check if it works) f=open('yourfilename') D={} for line in f: email,num = line.split() if email in D: D[email] = D[email]

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Pete Biggs
On Wed, 2017-10-25 at 12:02 -0400, Mark Haney wrote: > I know this is for CentOS stuff, but I'm at a loss on how to build a > script that does what I need it to do. It's probably really logically > simple, I'm just not seeing it. Hopefully someone will take pity on me > and at least give me a

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Mark Haney
On 10/25/2017 12:33 PM, Robert Arkiletian wrote: here is a python solution #!/usr/bin/python #python 2 (did not check if it works) f=open('yourfilename') D={} for line in f: email,num = line.split() if email in D: D[email] = D[email] + num else: D[email] = num

Re: [CentOS] [OT] Bash help

2017-10-25 Thread Robert Arkiletian
On Wed, Oct 25, 2017 at 9:02 AM, Mark Haney wrote: > I know this is for CentOS stuff, but I'm at a loss on how to build a script > that does what I need it to do. It's probably really logically simple, I'm > just not seeing it. Hopefully someone will take pity on me and

[CentOS] [OT] Bash help

2017-10-25 Thread Mark Haney
I know this is for CentOS stuff, but I'm at a loss on how to build a script that does what I need it to do.  It's probably really logically simple, I'm just not seeing it.  Hopefully someone will take pity on me and at least give me a big hint. I have a file with two columns 'email' and