加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-05-23 07:06:44 所属栏目:Linux 来源:互联网
导读:在 Linux机器上,我想检查是否存在特定的套接字文件.我知道套接字文件存在,但我在bash中的检查没有向我显示: $ls -l /var/run/supervisor.socksrwxrw-rw- 1 root root 0 Jun 3 13:30 /var/run/supervisor.sock # == THE FILE EXISTS!!$if [ ! -f /var/run/su

在 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用于常规文件.

见男人1测试:

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

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读