3 ms·
Scripts in which you have both cut and awk are not simpler or clearer than ones in which you only use awk.
by kazinator 8y ago
Scripts in which you have both cut and awk are not simpler or clearer than ones in which you only use awk.
- mmt 8y agoAlthough I completely agree with this for any given "one-liner" or pipeline (even if it's multiple lines), I don't believe the mere use of awk in one place in the script means using cut elsewhere isn't simpler/clearer there. Consider a script that originally had now awk but just a field=$(somecmd | cut -d: -f3) but now has been modified to have awk elsewhere. Did the above just become less simple or clear? If so, is it worth changing it to the below for clarity? Does it matter if the awk predates the cut, instead? field=$(somecmd | awk -F: '{print $2}') I say "no" to both, although I do recognize the argument for just using the same, consistent tool everywhere, instead.