Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 952
  • Last Modified:

'find' linux command - filter out directories

I'm running this command:
find . > tmp.txt

but it also includes the directory names it finds along the way. Is there a way to filter out the directories?

Thanks
0
MaritimeSource
Asked:
MaritimeSource
1 Solution
 
AutogardCommented:
There is a "type" option in find...

=== From the man page for 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 (never true if the -L option or the -follow option is in effect, unless the symbolic link is broken).
              s      socket
              D      door (Solaris)
==============================

So try "find -type f > tmp.txt" (or something similar).
0
 
AutogardCommented:
My post above will tell it to find just regular files.  But actually if you want to find anything BUT directories then try one of these...

"find ! -type d > tmp.txt"
or
"find \! -type d > tmp.txt"

(source: http://lists.debian.org/debian-user/1996/09/msg00474.html)
0
 
ranadastidarCommented:
try with locate tmp.txt
0
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

 
ahoffmannCommented:
Autogard's comment is the answer to the question, locate is (horrible) unreliable.
0
 
ico2Commented:
locate is faster than find though
0
 
ahoffmannCommented:
<off-topic>
doesn't matter how fast imagination is, I'll wait for the truth ;-)
</off-topic>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now