Sorting Fields within a record

38 Views Asked by At

I have a very simple test.rec file with a small descriptor and 2 records.

%rec: Test
%mandatory: Foo
%mandatory: Bar

Foo: yes
Bar: yes

Bar: no
Foo: no

recfix is perfectly fine with this, however I am not. I would like every record to have its Foo field at 0 and its Bar field at 1.

I am aware of the %sort descriptor, its semantics and that it will only affect print order, not file storage order (unless explicitly invoking recfix --sort test.rec). recsel test.rec will print:

Foo: yes
Bar: yes

Bar: no
Foo: no

This is not what I want. I want:

Foo: yes
Bar: yes

Foo: no
Bar: no

Ideally i would like to declare my desired field order such that recfix can rearrange miss-sorted records in my file and not just print them out using some variation of recfmt.

Of course i could just write a script using any other unix-utility to do this for me, but Id be suprised if this wasnt possible with recutils itself.

0

There are 0 best solutions below