-4

How do i show pipe or socked files from a directory?

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

closed as off-topic by Jeff Schaller, jimmij, Scott, vonbrand, chaos Jan 7 '16 at 20:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – Jeff Schaller, jimmij, Scott, vonbrand, chaos
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 7
    You should try reading up on man find and go to the -type section which shows the different types of "files" that it can look for, including both pipes and sockets – Eric Renouf Jan 7 '16 at 16:27
2

From the find man page:

   -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)

The flags you're looking for are -type s for sockets and -type p for pipes (or FIFO's)

EDIT: If you want to list files that are either a socket or a pipe then you'll need to specify an 'OR' in the command. For example find . \( -type s -o -type p \)

  • what if i want to show both of them in one line? – ted Jan 7 '16 at 16:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.