4 ms·
AWK is the general-purpose programmatic filter and reporting tool in the Unix pipeline. Sed, grep and cut are specializations for specific use cases whose imple
by bluetomcat 9y ago
AWK is the general-purpose programmatic filter and reporting tool in the Unix pipeline. Sed, grep and cut are specializations for specific use cases whose implementations might have better performance. Perl and Python are probably too general-purpose for writing compact one-liners in a pipeline.
- rflrob 9y agoEven though it's more characters, I usually use perl -pe 's/search/replace/' instead of sed in pipelines because it understands /n (and other escape characters I don't remember). Because all it takes is to get burned a couple times for it to be worth sticking with what you know will work.
- _delirium 9y agoThe Perl version is considerably faster on large files as well. Or at least, it is when compared to the version of BSD sed shipped with OSX.
- kronos29296 9y agoThis is probably not the case with the sed in Linux.
- dozzie 9y ago"/n"? What's that? My `man perlre' doesn't say anything about this regexp flag.
- tribby 9y agobecause OP is referring to escape characters I assume it is a typo for "\n"
- jwilk 9y agoProbably not what rflrob meant, but /n prevents parentheses from capturing. https://perldoc.perl.org/perlre.html#%2an%2a https://perldoc.perl.org/perlre.html#%2an%2a
- dozzie 9y agoThis is somewhat surprising. A relatively new feature, and not present in my current Perl.