使用bash shell脚本锁定文件区域

时间:2022-11-15 21:43:57

I am trying write some script with which i can try to lock a region of file using bash shell script.

我正在尝试编写一些脚本,我可以尝试使用bash shell脚本锁定文件区域。

I have used flock, but it locks the whole file and does not provide parameters to lock a region of a file like in C language you get with fcntl.

我使用了flock,但它锁定了整个文件,并没有提供用于锁定文件区域的参数,就像用fcntl获得的C语言一样。

Will be helpful someone can provide some suggestions in this area?

有帮助的人可以在这方面提供一些建议吗?

1 个解决方案

#1


1  

As you use flock (1) (which is a C program, see http://util-linux.sourcearchive.com/documentation/2.17/flock_8c-source.html) to utilize flock (2), you would need a similar command that utilizes fcntl. If such a command doesn't exist yet, one would have to write it.

当您使用flock(1)(这是一个C程序,请参阅http://util-linux.sourcearchive.com/documentation/2.17/flock_8c-source.html)来使用flock(2)时,您需要一个类似的命令利用fcntl。如果这样的命令还不存在,则必须编写它。

#1


1  

As you use flock (1) (which is a C program, see http://util-linux.sourcearchive.com/documentation/2.17/flock_8c-source.html) to utilize flock (2), you would need a similar command that utilizes fcntl. If such a command doesn't exist yet, one would have to write it.

当您使用flock(1)(这是一个C程序,请参阅http://util-linux.sourcearchive.com/documentation/2.17/flock_8c-source.html)来使用flock(2)时,您需要一个类似的命令利用fcntl。如果这样的命令还不存在,则必须编写它。