Next: , Up: Inserting Records   [Contents][Index]


4.1.1 Adding Records With recins

Each invocation of recins adds one record to the targeted database. The fields comprising the records are specified using pairs of -f and -v command line arguments. For example, this is how we would add the first entry to a previously empty contacts database:

$ recins -f Name -v "Mr Foo" -f Email -v foo@bar.baz contacts.rec
$ cat contacts.rec
Name: Mr. Foo
Email: foo@bar.baz

If we invoke recins again on the same database we will be adding a second record:

$ recins -f Name -v "Mr Bar" -f Email -v bar@gnu.org contacts.rec
$ cat contacts.rec
Name: Mr. Foo
Email: foo@bar.baz

name: Mr. Bar
Email: bar@gnu.org

There is no limit on the number of -f -v pairs that can be specified to recins, other than any limit on command line arguments which may be imposed by the shell.

The field values provided using -v are encoded to follow the rec format conventions, including multi-line field values. Consider the following example:

$ recins -f Name -v "Mr. Foo" -f Address -v '
Foostrs. 19
Frankfurt am Oder
Germany' contacts.rec
$ cat contacts.rec
Name: Mr. Foo
Address:
+ Foostrs. 19
+ Frankfurt am Oder
+ Germany

It is also possible to provide fields already encoded as rec data for their addition, using the -r command line argument. This argument can be intermixed with -f -v.

$ recins -f Name -v "Mr. Foo" -r "Email: foo@bar.baz" contacts.rec
$ cat contacts.rec
Name: Mr. Foo
Email: foo@bar.baz

If the string passed to -r is not valid rec data then recins will complain with an error and the operation will be aborted.

At this time, it is not possible to add new records containing comments.


Next: , Up: Inserting Records   [Contents][Index]