bug-recutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-recutils] use of recsel when records contain multiple instances


From: Charles Millar
Subject: Re: [bug-recutils] use of recsel when records contain multiple instances of same field-name in each record (was use of)
Date: Wed, 19 Apr 2017 15:06:08 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0


On 04/19/17 10:01, Eric Nystrom wrote:
Glad that technique can solve your problem!

It works because the first invocation of recsel selects all from the file that have the first Tag, and writes those to output.  Then the "pipe" feeds that first output into the second recsel as input, where it chooses those with the second Tag.

OK. recsel output may be in the form of a record, so the input to the second recsel is a record as well. As an experiment I filtered the first recsel with -p Name, which would print out the field label and value; results OK. On the other hand  -P Name causes an error since -P only produces the value without the field name, i.e. no record.
I do agree it would be nice to be able to accomplish this in a single _expression_.

Best,

-Eric


On Apr 19, 2017 6:47 AM, "Charles Millar" <address@hidden> wrote:

Thank you, Eric.

The following does give me the output I desire

recsel -e 'Tag = "This"' Contacts.rec | recsel -e 'Tag = "That"' -p Name

However, why? Please note that the last recsel does not have a recfile as the final argument.

BTW, I did try your idea with one of my "real world" recfiles using different combinations and each time the output was as expected.

Still, a one recsel SEX would be nice.

Charlie

On 04/18/17 21:38, Eric Nystrom wrote:
This doesn't directly address the sexexp question, but you could do recsel with the first selection, then pipe that into recsel again to select with the second _expression_.

Best regards,

-Eric


On Apr 18, 2017 5:31 PM, "Charles Millar" <address@hidden> wrote:
I am attempted to construct a recsel SEX for the following Contacts.rec file  that will result with Person 1 and Person 3

Name; Person 1
Tag: This
Tag: That
Tag: These

Name: Person 2
Tag: These
Tag: This

Name: Person 3
Tag: That
Tag: These
Tag: This

Name: Person 4
Tag: This
Tag: Those
tag: These

Name: Person 5
Tag: That

One of my attempts

recsel -e \( 'Tag ~ "This"' && 'Tag ~ "That"' \) -P Name Contacts.rec

returns the command prompt only (no error message)

Please note that "Tag" is the field name (label) and that the field values for "Tag" may entered randomly, and sometimes later when the rec file is updated and that each contact may have any number of "Tags". Therefore I do not believe that using subscripts such as Tag[1] would be useful.

Also, the "recsel -e 'Tag ~ "This"' -P Name Contacts.rec" does return a lsit of Persons 1 - 4

I have very little (i.e. nil) regex knowledge, so any help would be appreciated.

If this rescel is not possible, could this be considered as a future enhancement to Recutils?

Charlie Millar






reply via email to

[Prev in Thread] Current Thread [Next in Thread]