LinuxCommandLibrary

recfmt

TLDR

Format records with template

$ recfmt -f "[template]" [file.rec]
copy
Use template file
$ recfmt -t [template.fmt] [file.rec]
copy
Format specific type
$ recfmt -s [Type] -f "[template]" [file.rec]
copy

SYNOPSIS

recfmt [options] [file]

DESCRIPTION

recfmt formats GNU recutils records using a template. It allows custom output formatting with field substitution, useful for generating reports or custom views.
Part of GNU recutils.

PARAMETERS

-f, --format template

Format template string.
-t, --template file
Template file.
-s, --type type
Record type to format.

EXAMPLES

$ # Simple format
recfmt -f "Name: {{Name}}, Email: {{Email}}" contacts.rec

# From template file
recfmt -t report.fmt data.rec

# Specific record type
recfmt -s Book -f "{{Title}} by {{Author}}" library.rec

# Combine with selection
recsel -e "Status = 'active'" items.rec | recfmt -f "- {{Name}}"
copy

TEMPLATE SYNTAX

$ {{FieldName}}          - Field value
{{#FieldName}}...{{/}} - Conditional
{{FieldName|default}}  - Default value
copy

TEMPLATE FILE

$ # report.fmt
=== {{Name}} ===
Email: {{Email}}
Phone: {{Phone}}
---
copy

CAVEATS

Template syntax differs from other templating systems. Part of GNU recutils.

HISTORY

recfmt is part of GNU recutils by Jose E. Marchesi for flexible record formatting.

SEE ALSO

recsel(1), rec2csv(1), recutils(7)

Copied to clipboard