Thoughts regular expressions in, for example sed

Patrick Asselman iceblink at seti.nl
Mon Jan 14 10:25:48 UTC 2013


On 2013-01-12 17:04, Paul Smith wrote:
> I'll repeat something I said the other day: you should be learning a
> more sophisticated scripting language like Perl.  Perl has all the
> capabilities of shell, sed, awk, and just about any other UNIX tool
> built in, plus capabilities none of the others can match.  And it has 
> a
> regular and consistent syntax, ability to handle unusual filenames
> without glitching, etc.  And it is installed, and runs, everywhere.
>
> I've been working on UNIX systems for... a really, really long time
> (since before Linus sat down to write his first kernel).  My personal
> rule is that if a shell script I'm writing ever gets longer than 
> about
> 25 lines or so, OR if it ever seems necessary to use awk, I chuck it 
> and
> write it in Perl instead.  Sed is fine, but if I need awk I might as
> well switch to Perl.

Though Perl is very powerful and you can create very short scripts with 
it (I believe there are even contests for that?), the problem I found 
myself facing was that when I had to modify a script I had written a 
half year ago, I needed to decipher the whole script from scratch. This 
is probably partly due to myself not adding enough comments, partly 
because I don't use it often, and partly also because I'm not a 
programmer. But after switching to Python I was much happier editing 
scripts after long periods of time, because everything is much more 
readable (and yes: probably also much more lengthy).

But of course everything has its own pro's and con's. Python 3 made 
some pretty radical changes to trivial things such as changing the print 
statement into a print() function. Quite annoying to see your scripts 
fail on such trivial statements, but on the other hand: better to change 
it sooner rather than later, if you are going to change it anyway, for 
the benefit of language consistency.

Best regards,
Patrick Asselman





More information about the ubuntu-users mailing list