Hacker News new | ask | show | jobs
by xupybd 2042 days ago
I really don't understand the love of one liners. Yes it's cool to see how much can be done in one line but it's so much harder to read. Isn't legibility far better than compactness?
3 comments

Aye, in general legibility >> compactness. Apart from the intellectual exercise (fun; !work), one-liners imo come in handy in:

>some_complex_tool | 'my one liner' | some_other_complex_tool > result.txt

Not putting the one-liner logic into a separate script avoids an additional lookup for someone learning what is going on, along with any deployment/path/.. dependencies to that separate script.

It depends on the context. I like one-liners because it's much easier to iterate over a command line and building them is a bit of a personal challenge since it's not worth writing a script or saving to a file.

I don't know about most people, but interactively I use short flags and when writing Bash scripts I try hard to use long flags and will often break things up specifically for clarity.

Yeah the challenge is a lot of fun I have to admit that.
Only advantage I can think of is that you can just paste it in a shell prompt, if you're not comfortable with making a script, changing permissions, etc.