Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如何使用statlinux命令检查文件是否已更改_Regex_Linux_Shell_Grep_Openwrt - Fatal编程技术网

Regex 如何使用statlinux命令检查文件是否已更改

Regex 如何使用statlinux命令检查文件是否已更改,regex,linux,shell,grep,openwrt,Regex,Linux,Shell,Grep,Openwrt,我想使用statlinux命令检查文件是否已更改或没有更改 linux@server:~/$stat test.txt文件:`test.txt'大小:23 块:8 IO块:4096常规文件设备:802h/2050d 索引节点:4887765链接:1 访问:(0644/-rw-r--)Uid:(1000/anis)Gid:(1000/ (安妮斯) 访问时间:2014-07-07 16:34:42.476315578+0200 修改:2014-07-08 12:54:15.756553868+020

我想使用statlinux命令检查文件是否已更改或没有更改

linux@server:~/$stat test.txt文件:`test.txt'大小:23
块:8 IO块:4096常规文件设备:802h/2050d 索引节点:4887765链接:1

访问:(0644/-rw-r--)Uid:(1000/anis)Gid:(1000/
(安妮斯)

访问时间:2014-07-07 16:34:42.476315578+0200

修改:2014-07-08 12:54:15.756553868+0200

更改:2014-07-08 12:54:15.756553868+0200

我们可以看到变化的时间。 目的是使用此更改时间检查文件是否已修改

linux@server:~/anis$stat test.txt|grep Change
更改:2014-07-08 12:54:15.756553868+0200

linux@server:~/anis$stat test.txt | grep Change

更改:2014-07-08 15:14:03.107977776+0200


那个么,如何让脚本在无限循环中运行以检查时间是否发生了变化呢

不要使用
stat
。要简单地阻止直到文件被修改,请使用
inotifywait

inotifywait -e modify test.txt
您可能希望等待一组限制性较小的更改:

inotifywait test.txt
将一直阻止,直到文件上发生任何事件。同时,考虑用户的心智:

inotifywait -qq test.txt

如果您使用的是OpenWrt Buildroot,那么您可以在配置期间选择并安装inotify工具(make menuconfig,或者您正在使用的任何配置ui)

之后,您可以按照William Pursell的建议使用inotifywait


with于2011年添加了inotify工具包。

也许可以查看
inotify
而不是轮询。
man-inotifywait
man-inotifywait
inotifywait在OpenWrt上运行?因为inotifyd在openwrt上不起作用,所以这个问题被标记为“linux”。如果您需要嵌入式系统的解决方案,应该在问题或标签中指定。事实上,我第一次在OpenWrt上安装inotify,但它不起作用,因此,我寻求使用其他工具的解决方案。