15 Kasım 2021 Pazartesi

find komutu symbolic link arama seçenekleri

Giriş
Açıklaması şöyle
Some folders may contain symbolic links that link to another part of your file system. As such, you might unknowingly search a much larger set of folders, if symbolic links do exist. As such, there are a number of options that control what happens when find comes across a symbolic link:
  • -P - when used, symbolic links are never followed.
  • -L - when used, symbolic links are always followed.
  • -H - when used, symbolic links are only followed if mentioned somewhere on the command line, i.e. if you search for a link, and there is a symbolic link called link, find will return a link along with anything found when following that symbolic link.
Açıklaması şöyle
  -P     Never follow symbolic links.  This  is  the  default  behaviour.
          When find examines or prints information a file, and the file is
          a symbolic link, the information used shall be  taken  from  the
          properties of the symbolic link itself.

   -L     Follow symbolic links.  [...]

   -H     Do  not  follow symbolic links, except while processing the com‐
          mand line arguments.  When find examines or  prints  information
          about  files, the information used shall be taken from the prop‐
          erties of the symbolic link itself.  The only exception to  this
          behaviour is when a file specified on the command line is a sym‐
          bolic link, and the link can be resolved.  For  that  situation,
          the  information  used is taken from whatever the link points to
          (that is, the link is followed).  The information about the link
          itself  is used as a fallback if the file pointed to by the sym‐
          bolic link cannot be examined.  If -H is in effect  and  one  of
          the  paths specified on the command line is a symbolic link to a
          directory, the contents  of  that  directory  will  be  examined
          (though of course -maxdepth 0 would prevent this).
-H seçeneği
Şöyle yaparız. Ubuntu'da /bin artık symbolic link. Ancak komut satırından girince find komutu takip etsin istiyoruz.
find -H /bin -iname 'sh*'
Eğer -H seçeneğini kullamazsak şöyle yapınca bir sonuç alamayız
$ find /bin -iname 'sh*'

Hiç yorum yok:

Yorum Gönder