3 ms·
I admire your work. Clever usage of unix tools is very handy. But for parsing text, do you really see that awk and Unix tools as a better solution then a simple
by klhugo 8y ago
I admire your work. Clever usage of unix tools is very handy. But for parsing text, do you really see that awk and Unix tools as a better solution then a simple python script?
Although I admit that the key argument for Unix tools is that they don’t get updated. That sounds awful, but think about it, once it works, it works everywhere, no matters OS type, version or packages installed. That is something experienced programmers always want from their solutions.
- mirceal 8y agoparsing text is what a lot of these scripts/mini-pipelines do. the key argument for *nix tools is that they do one thing and only one thing extremely well. at a meta level these tools are units of functionality and you’re actually doing functional programming, on the command line, without realizing it.
- IshKebab 8y agoThe problem is there are like 5 different tools that do the same "one thing" well - awk, sed, grep, cut, etc. Kind of simpler to learn one language that does lots of things well!
- mirceal 8y agoi’m going to respectfully disagree. each tool you listed (with the exception of awk) does one thing and does it extremely well. my goal is not to use a language to solve all possible variations on problems i have. my goal is to solve the problem. another interesting side effect is that a lot of times this is super compact and good enough. when it’s not you can go to a programming language
- MisterOctober 8y ago^ agree -- I've seen lots of folks [newer users mostly] turn to grep when really what they wanted was sed. It's just a matter of learning which screwdriver is for which type of screw
- faho 8y agoIsn't sed's "one thing" a superset of grep's?
- twic 8y agoPython is fantastic for little (or large!) bits of logic, but its handling of input is clunky enough to put me off for tiny things. AFAIK the boilerplate you need to get to working on the fields on each line is: import sys for line in sys.stdin: fields = line.split() # now you can do your logic If you want to use regular expressions, that's another import. Python also doesn't play well with others in a pipeline. You can use python -c, but you can't use newlines inside the argument (AFAICT), so you're very limited in what you can do.
- ryl00 8y agoThis is exactly where perl (namely, perl -ne) is so very, very useful.
- usefulcat 8y agoTotally agree. On a related note, I came across a similar thing just the other day for rubyists: https://github.com/thisredone/rb https://github.com/thisredone/rb Probably not as fast as many of the individual unix tools it could replace, but does look like a great way to leverage one's knowledge of ruby.
- twic 8y agoYes, that helps a lot. The fact that Perl uses braces rather than whitespaces also makes it work much better in this situation. I still wouldn't touch Perl with a bargepole, though. Sorry not sorry.