#### 3.20.12.3 Delete Records ¶

To delete records, use the `delete` subcommand. It reads a list of keys to delete to be specified as arguments in the command line:

    mailutils dbm delete file.db foo bar

The command above will delete from `file.db` records with keys ‘`foo`’ and ‘`bar`’.

It is not an error to attempt to delete a key that does not exist in the database, although such use will produce a warning message.

By default, keys are matched literally. It is also possible to use various pattern matching techniques, depending on the option specified.

The `--glob` (`-G`) option instructs the tool to use UNIX globbing pattern matching. For example, the command below will delete all keys starting with ‘`foo`’ and ending with a decimal digit:

    mailutils dbm delete file.db 'foo*[0-9]'

(note the quoting necessary to prevent shell from interpreting the metacharacters itself).

Another option, `--regex` (`-R`) instructs `mailutils` to treat supplied keys as extended regular expressions:

    mailutils dbm delete --regex file.db 'foo.*[0-9]{1,3}'

Both options are affected by the `--ignore-case` (`-i`) option, which turns on case-insensitive matching.

Using pattern matching to delete records can be a risky operation as selecting a wrong pattern will lead to removing wrong records. It is recommended to first use the list mode described below to verify that the patterns match the right keys.