1.

Solve : How to show the depth of a file by a single command??

Answer»

Hi all,

I am a Unix noob, just started learning unix.
I logged on to school's Solaris machine to practice unix commands
here is a question that is pretty TRICKY to me,

SHOW the depth of a regular file in a directory.

I tried to use find command with -printf %d to show the file's depth, but I got error
message: find: bad option -printf

anybody can help me solve this question?

Thanks a lot

i do not have a Solaris machine right now, however, i believe Solaris version of find doesn't have the -printf option. however i may be wrong, so check the man page. TYPE man find. see if there's one.
If there is, the correct syntax is
Code: [Select]find /path -type f -printf "%f:%d"
if the version doesn't support printf, and if you still want to find the depth, you can DOWNLOAD GNU find. Hi ghostdog74

Thanks for the reply
I think you are right, the "find" command dose not have "printf" option on Solaris machine,
however I found other way to do it, set "/" as delimiter, and then count the NUMBER of column,
am I right?

Thanks
i wouldn't know if its right unless you show how you did it ?



Discussion

No Comment Found