bash 为什么bash无法识别套接字文件的存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37618443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why can't bash recognize the existence of a socket file
提问by kramer65
On a Linux box I want to check if a specific socket file exists. I know the socket files exists, but my checks in bash don't show that to me:
在 Linux 机器上,我想检查是否存在特定的套接字文件。我知道套接字文件存在,但我在 bash 中的检查没有向我显示:
$ ls -l /var/run/supervisor.sock
srwxrw-rw- 1 root root 0 Jun 3 13:30 /var/run/supervisor.sock # <== THE FILE EXISTS!!
$ if [ ! -f /var/run/supervisor.sock ]; then echo 'file does not exist!'; fi
file does not exist!
Why oh why can't bash see that the file exists?
为什么哦为什么bash看不到文件存在?
回答by bodangly
http://www.tldp.org/LDP/abs/html/fto.html
http://www.tldp.org/LDP/abs/html/fto.html
Use -S
to test if its a socket. -f
is for regular files.
使用-S
测试如果一个插座。-f
用于常规文件。
See man 1 test
:
见man 1 test
:
-e FILE
FILE exists
-f FILE
FILE exists and is a regular file
...
...
-S FILE
FILE exists and is a socket