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

前端之家收集整理的这篇文章主要介绍了linux – 为什么bash不能识别套接字文件的存在前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Linux机器上,我想检查是否存在特定的套接文件.我知道套接文件存在,但我在bash中的检查没有向我显示
  1. $ls -l /var/run/supervisor.sock
  2. srwxrw-rw- 1 root root 0 Jun 3 13:30 /var/run/supervisor.sock # <== THE FILE EXISTS!!
  3. $if [ ! -f /var/run/supervisor.sock ]; then echo 'file does not exist!'; fi
  4. file does not exist!

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

解决方法

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

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

见男人1测试:

  1. -e FILE
  2. FILE exists
  3. -f FILE
  4. FILE exists and is a regular file
  5. ...
  6. ...
  7. -S FILE
  8. FILE exists and is a socket

猜你在找的Linux相关文章