Re: The ls command
On Fri 31 Oct 2025 at 14:25:05 (+0100), Nicolas George wrote:
> At this point it is important to remind people that the output of ls is
> meant for users, not programs. A script that uses ls for anything else
> than showing a list of files to the operator, a script that reads the
> output of ls and parses it, is almost certainly broken when it
> encounters some special characters, and if not it is at least needlessly
> complicated.
I'd agree with that, with the odd exception where the range of
filenames is strictly limited. For example, ls -t1 is hard to
beat for simplicity, compared with using find+printf+sort+cut
or find+stat+sort+cut.
Cheers,
David.
Reply to: