又发现问题了?

又发现问题了?

如何显示目录中的管道或 socked 文件?

echo "give name of directory: "
read directory
if  [ -d "$directory"   ]
then 
echo "thanks again"
else exit
fi
find $directory -maxdepth 1 -type f 
find $directory  -mtime -$integer2 -ls
find $directory -ctime -$integer2 -ls

答案1

find手册页:

   -type c
          File is of type c:

          b      block (buffered) special

          c      character (unbuffered) special

          d      directory

          p      named pipe (FIFO)

          f      regular file

          l      symbolic link; this is never true if the -L option or the -follow option is in effect, unless the symbolic link is broken.  If you want to search for symbolic  links
                 when -L is in effect, use -xtype.

          s      socket

          D      door (Solaris)

您正在寻找的标志-type s用于套接字和-type p管道(或 FIFO)

编辑:如果您想列出套接字或管道的文件,那么您需要在命令中指定“OR”。例如find . \( -type s -o -type p \)

相关内容