[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

'find' linux command - filter out directories

Posted on 2006-06-08
6
Medium Priority
?
937 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

649 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