shell+inotifywait的妙用
技巧1 Shell + inotifywait 的使用
在修改代码时,总会编译一下看一下,运行是否正常。但是每次写完还要切换make一下,比较麻烦。于是乎,发现inotifywait这个工具真好用。其详解见man inotify。
$ while inotifywait -e modify <file-name.c>; do make test; done
Setting up watches.
Watch established.
这一句就是循环调用inotifywait,如果有修改文件,就do一下。在写测试程序时非常好用。如果使用vim的话,在当前工作目录下又makefile文件的话,在vim命令模式下
:make
也能方便快捷执行make。
技巧2 shell while使用
比如我们想要实时查看某个socket连接状况,或者文件目录情况。就可以这样写:
$ while true; do ll && sleep 3 && clear; done
技巧3 vim指定stdin
$ ll | vim #error cmd
这样并不能直接重定向到vim。
$ strace ./a.out |& vim -

浙公网安备 33010602011771号