3 ms·
Could you explain how writing, for example, text manipulation, would be safer in python than in shell? I understand formatting errors, shell escape failures, an
by arca_vorago 10y ago
Could you explain how writing, for example, text manipulation, would be safer in python than in shell? I understand formatting errors, shell escape failures, and the low hanging fruit, but in the end if I am just sed and awking my way around, I don't know how to do nearly the level of stuff I do in awk in python.
I also will never forget the time I spent a day doing a perl script to parse some data... took some time, came back, and did it in a one line awk... Very powerful.
I think somewhere in here is room for discussion of data, text, and the unix philosophy as everything as a file.
- makecheck 10y agoI said scripts with “growing complexity” should be expressed differently. I can and do use shell scripts for things that are relatively straightforward, and sed/awk-style transforms are a good example (although, even there, if too many quotes are involved you start to long for real escaping and things like triple-quotes).
- omaranto 10y agoA one-liner in Awk is almost certainly also a one-liner in Perl.
- arca_vorago 10y agoI didn't say I wasn't doing the perl badly.
- highd 10y agoIt's an issue of comprehensibility, not any current performance metric.
- ams6110 10y agoComprehensible to who? Other python programmers? Most sysadmins do not use python routinely. They work in the shell all day every day though.
- Godel_unicode 10y agoYou're assuming that shell and Python which do the same thing are equivalently readable to a proficient user. As someone who frequently uses both, I would strongly disagree with that. I have inherited lengthy shell scripts which probably took as long to read as it would have taken to learn Python. I would argue that a well written Python script is going to be more comprehensible to the average sysadmin than an equivalent shell script, even assuming the sysadmin is more conversant in shell. More portable and testable (!!) too.