z2oeta
Last Updated: February 25, 2016
·
763
· janosgyerik
32ef4e3e388cbadc756a008cade3ee6a

Find the longest path on your OS

Somebody asked me today:

Is there a command to run to find the longest path + filename on your OS?

This should do it in UNIX and similar:

find / | awk '{print length($0), $0}' | sort -n | tail

Or, a faster but less accurate way, if you have the locate command:

locate / | awk '{print length($0), $0}' | sort -n | tail

Of course, you can only find paths that your user has read permission for.

In Windows, using Git Bash, for drive C: and D: and E::

find /c /d /e | awk '{print length($0), $0}' | sort -n | tail

However, this might not work for very long paths (> 260), due to a limitation in the Windows API.

Say Thanks
Respond

2 Responses
Add your response

15803
C7826f5b297baebddbd568f4b69a2d98

Shouldn't locate . be locate /?

over 1 year ago ·
15804
32ef4e3e388cbadc756a008cade3ee6a

@hobarrera yes, well spotted! Thanks!

over 1 year ago ·