0

In the following command i want to search only only the directories which are non hidden how can i do this using the following command .Iwant to ignore hidden directories while searching the log file

  find /home/tom/project/ -name '.log.txt'    

Output:

    /home/tom/project/.log.txt
    /home/tom/project1/.log.txt

     find: Filesystem loop detected; ./.snapshot/hourly.0' has the same device number and inode as a directory which is 2 levels higher in the filesystem hierarchy. 
     find: Filesystem loop detected; ./.snapshot/hourly.1' has the same device number and inode as a directory which is 2 levels higher in the filesystem hierarchy.

I want eliminate all the find messages or do not serach in the hidden directory

  ls /home/tom/project/  
  dir1   
  dir2  
 .backup 
 .snapshot/
 .ignore/ 
Rajeev
  • 251
  • 1
  • 4
  • 10

2 Answers2

1

If you just want to ignore the error messages then redirect stdout to a file or /dev/null

find /home/tom/project/ -name '.log.txt' 2>/dev/null

If you may be interested in other error messages but not the particular ones you mention in your question then pipe the output through grep -v

find /home/tom/project/ -name '.log.txt' | grep -v 'Filesystem loop detected'
user9517
  • 115,471
  • 20
  • 215
  • 297
0

Try
find . -name '.log.txt' ! -wholename ".*.*/.log.txt"

Find all files with name = .log.txt, but also make sure file full path does not contain more than one DOT in the folder section. First dot is current directory.

If instead of current directory, an absolute path is provided, use following command
find . -name '.log.txt' ! -wholename "*.*/.log.txt"

bbaja42
  • 161
  • 2
  • 11
  • General logic is centered around detection of hidden folders in unix. Hidden folder starts with a DOT. – bbaja42 Mar 28 '12 at 07:21
  • The output is still ther same cannot surpass the snapshot directory – Rajeev Mar 28 '12 at 09:10
  • The `find` command will still check all sub directorys, but it will show in output only the ones with correct match. It seems taht Iain's answer could help you in that regard. Note, I don't understand why is that error shown, since `find` ,by default, does not follow any links. – bbaja42 Mar 28 '12 at 14:34