Find the answer to your Linux question:
Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Finding Directories With "Find" Command?

    Hi again,

    I'm having trouble trying to use the find command to find a directory. I purposely made a directory in:
    Called "OMG" and it's really got me baffled how I can find it in the terminal window. I can easily use the "find" command to find files but for some reason it doesn't allow me to find directories. Anyway here is the command I am using:

    find "OMG" -type -d -print

    And, sadly, it doesn't find it.

    What I would like it to acheive is to find the directory and list it's path. If someone can help me with this issue, it would make me a lot happier

  2. #2
    Trusted Penguin Dapper Dan's Avatar
    Join Date
    Oct 2004
    The Sovereign State of South Carolina
    I seldom use the find command and always rely on 'locate'
    locate "OMG"
    It might say you need to update your database. If so:
    If it says the database file can't be found then it needs to be created.
    updatedb -u
    Then try the first command again.
    Linux Mint + IceWM Registered: #371367 New Members: click here

  3. #3
    Quote Originally Posted by InvisibleSniper
    find "OMG" -type -d -print
    Your syntax is incorrect.
     find /directory/to/search -type -d -name "OMG"
    -print isn't necessary as that is the default.

  4. $spacer_open
  5. #4
    I wanted to do a recursive search and search through every directory without specifying any of them. Anyway I managed to do it with my command syntax I was origionally using, the only problem is that I had to login as 'SU' to do it... 'sudo' didn't work for some reason.

  6. #5
    Just Joined!
    Join Date
    Sep 2005
    New delhi
    Go through for further more complicated examples.

  7. #6

    Finding Directories With "Find" Command

    Using / will start the search from the root, so you don't have to remember where it might be. Specifying -type d first may speed up your search. Not sure about sudo.

    sudo find / -type d -name 'OMG'

  8. #7
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Closing this old thread.
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts