4 ms·
Is it just me or do most of these seem like premature optimization? I would rather use one command for filtering lines (grep) and another for filtering columns
by greg 18y ago
Is it just me or do most of these seem like premature optimization? I would rather use one command for filtering lines (grep) and another for filtering columns (awk) than try to do both at once.
- kaens 18y agoIt depends on how often you need to write scripts of this sort. If you only write them once in a while, you're probably fine with using two commands, but if you write scripts all the time, it's worth it to know how to do them succinctly.
- jkmcf 18y agoI generally take the definition of "premature optimization" to be "going out of your way to improve performance". If you know a faster (better?) way, use it. Sometimes, people seem to confuse YAGNI and premature optimization with just "knowing better". For your grep example, unless you are using the output of grep for something else, there's no reason not to use the awk version except ignorance (which I'm plenty guilty of re: awk and sed...)