6

Like every other person I am from time to time compelled to list the directory structure from a certain point int the filesystem. I do so with find /path/in/fs/ and this yields something like:

/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 

in a way this saves me from endless iterations of cd and ls.

Now I wanted to list the directory structure in the /sys/class path and I think it falls short. The next two commands show the odd behavior:

  • (1) using the cd and ls
 root@freak:/sys/class/hwmon# ls hwmon0 hwmon1 hwmon2 root@freak:/sys/class/hwmon# cd hwmon0 root@freak:/sys/class/hwmon/hwmon0# ls name power subsystem temp1_crit temp1_input uevent 
  • (2) using the said find command at the same place
 root@freak:/sys/class/hwmon# find . . ./hwmon0 ./hwmon1 ./hwmon2 

As you can see it seems to me that find does not show me everything, which I find an odd and suprising behavior. Now I know that stuff below /sys/ is somehow special. Still it all works the cd ls way. Somebody has an answer why this happens and better even how I can make find not overlook the content in ./hwmon0 ./hwmon1 ... etc for instance?

7
  • 2
    hwmon0, hwmon1, and hwmon2 are probably symlinks. The actual location of those directories is elsewhere in the /sys hierarchy. Commented Mar 18, 2013 at 6:37
  • yip. thank you. how could I overlook that.. thank you. Commented Mar 18, 2013 at 6:40
  • since I mindelessly overlooked to check if it is symbolic links I cast my find on I have not received the result. A solution hence was to use find /sys/class/hwmon -follow -maxdepth 3 Commented Mar 18, 2013 at 6:51
  • if you want find all files in the same just use find /sys/class/ -type f Commented Mar 18, 2013 at 8:07
  • @humanityANDpeace just update your post , what you want in output ? and what you want to achieve... Commented Mar 18, 2013 at 8:14

1 Answer 1

5

When you run

find . 

then it will take -P by default Option , it is actually run find -P .

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

that's why find does not show you everything under /sys/class/hwmon, if you go inside and check it's all symbolic link, So you just need to check using find . -follow

For more information check man find

2
  • yes indeed, as already laid out in the comments by Celada and myself symbolic links have been the reason. Though not personally of additional use your answer can be of value for all the people who will hence have a Question and an Answer. I will accept it surely. Thank you! Commented Mar 20, 2013 at 6:42
  • -follow is deprecated. Use the '-L' option instead: find -L. PS: If the path is '.' then you can omit it. Commented Aug 17, 2021 at 19:12

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.