Find the answer to your Linux question:
Results 1 to 7 of 7
Hi again, I'm having trouble trying to use the find command to find a directory. I purposely made a directory in: totallylinux@superpc:/usr/share/azureus/plugins$ Called "OMG" and it's really got me baffled ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2006
    Posts
    28

    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:
    totallylinux@superpc:/usr/share/azureus/plugins$
    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
    Location
    The Sovereign State of South Carolina
    Posts
    4,630
    I seldom use the find command and always rely on 'locate'
    Code:
    locate "OMG"
    It might say you need to update your database. If so:
    Code:
    updatedb
    If it says the database file can't be found then it needs to be created.
    Code:
    updatedb -u
    Then try the first command again.
    Linux Mint + IceWM Registered: #371367 New Members: click here

  3. #3
    Just Joined!
    Join Date
    May 2006
    Posts
    31
    Quote Originally Posted by InvisibleSniper
    find "OMG" -type -d -print
    Your syntax is incorrect.
    Code:
     find /directory/to/search -type -d -name "OMG"
    -print isn't necessary as that is the default.

  4. #4
    Just Joined!
    Join Date
    May 2006
    Posts
    28
    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.

  5. #5
    Just Joined!
    Join Date
    Sep 2005
    Location
    New delhi
    Posts
    22
    Go through www.amitsharma.linuxbloggers.com/how_to_find.htm for further more complicated examples.

  6. #6
    Just Joined!
    Join Date
    Feb 2013
    Posts
    1

    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'

  7. #7
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,356
    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
  •