Link to home
Start Free TrialLog in
Avatar of hussainkhan22
hussainkhan22Flag for United States of America

asked on

Find command

Hey how can I find particular file name present in all file system in unix os. I really appreciate your help. Thanks in advance
Avatar of Tintin
Tintin

The clue is in your question :-)
find / -name "filename.txt"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of MURUGESAN N
MURUGESAN N
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hussainkhan22

ASKER

If I have same file names on different directories, so how can I find where all the same file name present in my server. thanks everyone for great solutions above
find will give you the full path.

Or maybe you want to find real duplicates? I guess that would deserve to be filed as a separate question, but you can look into cmp or fdupes.
Hi,

Have a look at a GNU utility called "locate" you can download the solaris binary from www.sunfreeware.com.

It is part of the findutils-4.4.2 package.

Here is the manual for locate.
http://unixhelp.ed.ac.uk/CGI/man-cgi?locate+1

And also the manual for updatedb
http://unixhelp.ed.ac.uk/CGI/man-cgi?updatedb+1

Basically you need to run the updatedb command and tell it which paths you want to index then you can use the locate command to find the filenames your after in multiple locations.


find command to search for linked files
find / -type l -name fileName

Open in new window

Example output in my Red Hat Linux  OS:
          [b]find / -type l  -name menu.lst
                    /boot/grub/menu.lst
          ls -l  /boot/grub/menu.lst
                    lrwxrwxrwx    1 root     root           11 Aug  9  2003 /boot/grub/menu.lst -> ./grub.conf[/b]
[code]




To search only for files
[code]
find / -type f  -name fileName

Open in new window

Example output(I created the file /home/murugesan/grub.conf):
          find / -type f  -name grub.conf
              /boot/grub/grub.conf
              /home/murugesan/grub.conf
          ls -l /boot/grub/grub.conf /home/murugesan/grub.conf
              -rw-r--r--    1 root     root          817 Aug  9  2003 /boot/grub/grub.conf
              -rw-r--r--    1 murugesan murugesan        0 Dec 31 10:32 /home/murugesan/grub.conf

Open in new window


From the manual of find command you can know more about the options used in find command.
Some text format change in the previous post.

find command to search for linked files
find / -type l -name fileName

Open in new window

Example output in my Red Hat Linux  OS:
           find / -type l  -name menu.lst
                     /boot/grub/menu.lst
           ls -l  /boot/grub/menu.lst
                     lrwxrwxrwx    1 root     root           11 Aug  9  2003 /boot/grub/menu.lst -> ./grub.conf

Open in new window


 
 
 
To search only for files
find / -type f  -name fileName

Open in new window

Example output(I created the file /home/murugesan/grub.conf):
          find / -type f  -name grub.conf
              /boot/grub/grub.conf
              /home/murugesan/grub.conf
          ls -l /boot/grub/grub.conf /home/murugesan/grub.conf
              -rw-r--r--    1 root     root          817 Aug  9  2003 /boot/grub/grub.conf
              -rw-r--r--    1 murugesan murugesan        0 Dec 31 10:32 /home/murugesan/grub.conf

Open in new window

From the manual of find command you can know more about the options used in find command.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

u can use
# find / -name filename