Home > Software design >  Sorting glob qualifiers do nothing in zsh
Sorting glob qualifiers do nothing in zsh

Time:06-02

I want to use the glob qualifiers in zsh to sort files by various criteria. For example, ls -l *(.oL) is supposed to return ordinary files sorted by size.

Everything else in zsh seems to work as advertised, but the sorting operators o and O have no effect. The results are always sorted by filename.

I’ve tried removing my .zshrc file, but that did not fix this.

I’m on Debian 11 and installed zsh from the repository, getting me v. 5.8.

CodePudding user response:

Charles Duffy is correct, it is ls that is re-sorting the files alphabetically. We can see this using his suggestions or simply by using echo.

ls has its own sorting flags, but I wanted to commit just one syntax to memory. Filename sorting in ls can be disabled with the -U flag.

It’s odd, because several popular guides to zsh that I consulted all use sorting examples with ls. Has ls changed its behavior recently? Is the version distributed with Debian unusual?

  • Related