$ cat inventory Item Amount Cost Value Description ---- ------ ---- ----- ----------- 1 4 50 150 rubber gloves 2 100 5 500 test tubes 3 5 80 400 clamps 4 23 19 437 plates
First we use seek to locate the record and return the offset and size.
$ LOCATION=`echo 3 | seek -mb inventory Item` $ echo $LOCATION 118 136 0 9
This means that the record is 118 bytes into the file and that it ends at byte 136. $$ is an automatic shell variable which provides the users' process ID. With this information we can unlock the record:
$ unlock inventory $$ $LOCATION $ cat /tmp/Linventory cat: cannot open /tmp/Linventory
unlock removes the whole file if the last lock line has been removed. SEE ALSO