• Wincent
    Menu
  • Blog
  • Wiki
  • Snippets
  • Tags
  • Search

Sorting filenames by length of stringEdit

Created 12/4/2020, updated 7/9/2021

I say "filenames" but is really could be any string.

Motivating use case: figuring out where the cut-off point is for filepaths in a Git repo overflowing the maximum permitted length on a Windows file system (example CI failure here).

git ls-files | perl -e 'print sort { length($b) <=> length($a) } <>'

Via: Stack Overflow

  • wiki
Site
  • About
  • Blog
  • Wiki
  • Snippets
  • Tags
  • Search
External
  • GitHub
  • Twitter
  • YouTube
  • Facebook
  • LinkedIn
Colophon

Made by Greg Hurrell with Rust (with help from Git and Neovim).