HN Hall of Fame Weekly email

You shouldn't parse the output of ls(1)

mywiki.wooledge.org Books & learning Tutorials & guides Software engineering Class of 2024-06 Hall of Fame
Screenshot of mywiki.wooledge.org captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 6 calendar years, with breakout response in 2 of them.

submissions
7
submitters
7
observed span
2014–2024
peak thread · 148 comments
149 pts
latest 20+ return · 2024-06-15
96 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

Some of these are why I bail for a “real language” in many seemingly simple scenarios. As soon as I care about datetimes, it’s just easier to use stat() and a proper datetime API. I can treat filenames as byte arrays and translate to Unicode or let the language do it for me. In dire circumstances, find … -print0 | xargs -0 second_script is usually my fallback, but that has pitfalls as well. Go has been a blessing there for…

salmo·149-point thread·

A number of people have commented that they’ve never experienced a filename with `\n`, or other weird characters, in the wild. On the contrary, I’ve seen this many many times, to the point that I’m defensive about how I write scripts, to compensate. In my case, these were files created by some other program that contained a bug, where the filename was accidentally set to something like the file contents, say. These other programs were often written by researchers, rather…

This is the big thing that disappointed and frustrated me after I had spent a bunch of time hacking on Lisp Machines and then switched to Unix: in the Unix world, everything but everything is character strings. On the LispM, when you called 'directory', you'd get back a list of pathname objects. All the system interfaces were like that; it was hardly ever necessary to parse anything -- and when you did have to, it would be in s-expression format…

The article doesn't mention "ls -1" at all, which has served me quite well in various more or less complex scripts over the years.

pferde·2-point thread·

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
2

100+ points or 50+ comments

Total points
285

reference only — not used in Hall rules or ranking

Total comments
251

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2014-07-06Why you shouldn't parse the output of lsdgellow3118
2015-01-20Why you shouldn't parse the output of ls(1)rosser20
2016-01-31Parsing lstambourine_man30
2018-12-24Why you shouldn't parse the output of ls(1)O1111OOO22
2021-09-06Parsing the output of ls is an antipatternpcr91030320
2021-12-31You shouldn't parse the output of ls(1)First breakout · Best threadtosh149148
2024-06-15Why you shouldn't parse the output of ls(1)Hall induction · Latest 20+ point returnsusam9683