?
Solved

'find' linux command - filter out directories

Posted on 2006-06-08
6
Medium Priority
?
930 Views
Last Modified: 2008-03-03
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
Comment
Question by:MaritimeSource
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Expert Comment

by:Autogard
ID: 16865219
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
 
LVL 8

Accepted Solution

by:
Autogard earned 2000 total points
ID: 16865253
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
 
LVL 5

Expert Comment

by:ranadastidar
ID: 16867439
try with locate tmp.txt
0
Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

 
LVL 51

Expert Comment

by:ahoffmann
ID: 16878214
Autogard's comment is the answer to the question, locate is (horrible) unreliable.
0
 
LVL 1

Expert Comment

by:ico2
ID: 16892722
locate is faster than find though
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16892755
<off-topic>
doesn't matter how fast imagination is, I'll wait for the truth ;-)
</off-topic>
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question