gpt4 book ai didi

linux - 为什么 bash 不能识别套接字文件的存在

转载 作者:IT王子 更新时间:2023-10-29 00:08:57 26 4
gpt4 key购买 nike

在 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!

为什么哦,为什么 bash 看不到文件存在?

最佳答案

http://www.tldp.org/LDP/abs/html/fto.html

使用-S 来测试它是否是套接字。 -f 用于常规文件。

参见man 1 测试:

   -e FILE
FILE exists
-f FILE
FILE exists and is a regular file
...
...
-S FILE
FILE exists and is a socket

关于linux - 为什么 bash 不能识别套接字文件的存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37618443/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com