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.
Written by Janos Gyerik
Related protips
2 Responses
Shouldn't locate .
be locate /
?
over 1 year ago
·
@hobarrera yes, well spotted! Thanks!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Awk
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#