/sys/class を見ると、すべての内容は表示されません。なぜですか?

/sys/class を見ると、すべての内容は表示されません。なぜですか?

他の人と同様に、私は時々ファイルシステムの特定の場所にあるディレクトリ構造を一覧表示する必要があります。このようにしましたが、find /path/in/fs/結果は次のとおりです。

/path/in/fs/subfolder1
/path/in/fs/subfolder1/file1
/path/in/fs/subfolder1/subfolder2/yetanothefile
/path/in/fs/subfolder1/subfolder2/yetanothefile2
/path/in/fs/subfolder1/subfolder2/yetanothefile3
/path/in/fs/subfolder1/file2

ある意味、これは無限の繰り返しcdls

/sys/classこれで、パスにディレクトリ構造を一覧表示したいが十分ではないようです。次の2つのコマンドは、奇妙な動作を示しています。

  • (1) 使用cd及びls
    root@freak:/sys/class/hwmon# ls
    hwmon0 hwmon1 hwmon2
    root@freak:/sys/class/hwmon# cd hwmon0
    root@freak:/sys/class/hwmon/hwmon0# ls
    名前 電源サブシステム temp1_crit temp1_input uevent
  • find(2) 同じ位置で上記のコマンドを使用してください。
    root@freak:/sys/class/hwmon# 検索 。
    ./hwmon0
    ./hwmon1
    ./hwmon2

ご覧のとおり、私の考えでは、これはfind私にすべてを示しているわけではなく、これは奇妙で驚くべき行動だと思います。これで/sys/の下に特別なものがあることがわかりました。しかし、すべてがまだ順調に進んでいますcd ls。なぜこれが起こるのかという答えを持っている人はいますか?または、./hwmon0 ./hwmon1 ...などの項目を無視しないようにするにはどうすればよいですか?

ベストアンサー1

走るとき

find .

-Pその後、実際に実行される Option にデフォルト設定されます。find -P .

から抜粋man find

   -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.

これがfindが以下の内容をすべて表示しない理由です/sys/class/hwmon。中に入って確認するとすべてシンボリックリンクなので確認する必要があります。find . -follow

詳しくはご確認くださいman find

おすすめ記事