Search a file in UNIX

Discussion in 'Unix' started by Poonamol, Apr 5, 2010.

  1. Poonamol

    Poonamol New Member

    Joined:
    Mar 31, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    How can I search any file in Unix from home directory?
    File is in sub directory. Search a file in dir and sub dir.

    Thanks in advance.
     
  2. en_7123

    en_7123 New Member

    Joined:
    Feb 11, 2010
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    0
    Use the find command.Read the man page
     
  3. Poonamol

    Poonamol New Member

    Joined:
    Mar 31, 2010
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for your reply.
    I got it

    find / -name "filename.extension" This lists all paths of the file in dir and subdirs also.:)
     
  4. kumarmannu

    kumarmannu Banned

    Joined:
    Feb 2, 2011
    Messages:
    51
    Likes Received:
    0
    Trophy Points:
    0
    Find files with the Linux find command : This first Linux find example searches through the root filesystem ("/") for the file named "Chapter1". If it finds the file, it prints the location to the screen. find / -name Chapter1 -type f -print A nice thing to know is that on Linux systems and modern Unix system you no longer need the -print option at the end of the find command, so you can issue it like this: find / -name Chapter1 -type f This next find command searches through the /usr and /home directories for the file named Chapter1: find /usr /home -name Chapter1 -type f To search in the current directory, and all subdirectories, just use the . character to reference the current directory in your find commands, like this: find . -name Chapter1 -type f
     
  5. shivkumar2

    shivkumar2 New Member

    Joined:
    Jan 11, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    find / -name file name -to find file and driectory in linux.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice