[Top][All Lists]

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

[bug-recutils] Unable to assign the value of Count contained in a variab

From: Héctor A . Abreu
Subject: [bug-recutils] Unable to assign the value of Count contained in a variable to -n option
Date: Sun, 8 Jul 2018 13:23:21 -0400
User-agent: Mutt/1.5.23 (2014-03-12)


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. It will only display the Name in last record 
correctly in the following cases:

1) When number_of_records is set to a constant value at the beginning of the 
script, like any of the following examples:

2) When the option -n is followed by any number between 0 and 2, for example:
name_in_last_record=$(recsel -P Name -n 1 contacts.rec)

I've checked that number_of_records=$(recsel -P "Count(Name)" contacts.rec) is 
assigning the value correctly. Please let me know if I need to add anything 
extra to that line, or if it's a bug.

Thank you in advance for all your help.
Héctor A. Abreu

reply via email to

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