$ cat inventory Item Amount Cost Value Description ---- ------ ---- ----- -------------- 1 3 50 150 rubber gloves 2 100 5 500 test tubes 3 5 80 400 clamps
We use seek to locate the record and return the offset and size.
$ LOCATION=`echo 2 | seek -mb inventory Item` $ echo $LOCATION 95 118 0 9
The numbers mean that the record is offset 95 bytes into the file and that it is 23 bytes long, ending at byte 118. The 0 and 9 mean that there is no secondary index file. Now we can call lock to lock the record:
$ lock inventory $$ $LOCATION $ cat /tmp/Linventory 1812 95 118 0 9
The $$ invokes the shell variable which provides our process id (1812). SEE ALSO