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
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
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
> >
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
>
> 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
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
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
> >
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
>
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
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
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:
> >>
> >>
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:
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
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,
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
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:
>
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] [
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
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
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
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
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
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
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
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
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 =
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
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]
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
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
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
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
32 matches
Mail list logo