bug-recutils
[Top][All Lists]
Advanced

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

Re: [bug-recutils] Unable to assign the value of Count contained in a va


From: Jose E. Marchesi
Subject: Re: [bug-recutils] Unable to assign the value of Count contained in a variable to -n option
Date: Mon, 09 Jul 2018 16:15:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

        
        I have the contacts.rec file below:
        
        Name: Granny
        Phone: +12 23456677
        
        Name: Doctor
        Phone: +12 58999222
        
        Name: Dad
        Phone: +12 88229900
        
        And I want to display the Name in the last record using the script
        script_variable_index.sh below:
        
        number_of_records=$(recsel -P "Count(Name)" contacts.rec)
        name_in_last_record=$(recsel -P Name -n "$number_of_records" 
contacts.rec)
        echo "Name in last record: $name_in_last_record"
        
        But I get the following output:
        
        Name in last record:
        
        So, not displaying any Name.
    
    That's because the aggregate Count(Name) is returning 3 (there are 3
    instances of the field Name), whereas -n expects a 0-based index.

BTW for counting records you can use recsel -c.



reply via email to

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