Just as recins
inserts records, the utility recdel
deletes them.
Consider the following recfile stock.rec:
%rec: Item %type: Expiry date %sort: Title Title: First Aid Kit Expiry: 2 May 2009 Title: Emergency Rations Expiry: 10 August 2009 Title: Life raft Expiry: 2 March 2009
Suppose we wanted to delete all items
with an Expiry
value before a certain date, we could do this with the following command:
$ recdel -t Item -e 'Expiry << "5/12/2009"' stock.rec
After running this command, only one record will remain in the file
(viz: the one titled ‘Emergency Rations’) because all the others have expiry dates
prior to 12 May 2009.
2
The -t
option can be omitted if, and only if, there is no %rec
field
in the recfile.
recdel
tries to warn you if you attempt to perform a delete operation
which it deems to be too pervasive. In such cases, it will refuse to run,
unless you give the --force
flag.
However, you should not rely upon recdel
to protect you, because it cannot
always correctly guess that you might be deleting more records than intended.
For this reason, it may be wise to use the -c
flag, which causes
the relevant records to be commented out, rather than deleted. (And
of course backups are always wise.)
The complete options available to the recdel
command are explained later.
See Invoking recdel.
‘5/12/2009’ means the 12th day of May 2009, not the fifth day of December,
even if your LC_TIME
environment variable has been set to suggest otherwise.