bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OT: automation


From: Arne Babenhauserheide
Subject: Re: OT: automation
Date: Wed, 28 Oct 2009 17:23:13 +0100
User-agent: KMail/1.12.2 (Linux/2.6.30-gentoo-r5; KDE/4.3.2; x86_64; ; )

Am Sonntag, 25. Oktober 2009 11:23:59 schrieb olafBuddenhagen@gmx.net:
> That's a very bad thing to do. I hate all these mmv and other bullshit

mmv? 

> *much* more valuable knowledge than usage of any specific scripts. This
> generic knowledge, once obtained, can be reused in all kinds of
> situations.

What I use of my shell is for loops, some globbing, pipes with sed, grep, find, 
and such. 

The reason I prefer python scripting is mainly shell escaping, which can 
really hurt :( 

Sometimes I haggle for minutes with a sed script, before I get it right. I 
think I should write me a python script which just takes stdin and some python 
commands as input, executes the commands on the file and pipes the result to 
stdout... 

Something like ... damn ... del 10 lines of unnecessary script ... 

find -print0 | python -c "from sys import stdin;from os.path import isfile
files = stdin.read()
for f in files.split('\0'):
   if isfile(f):
      data = open(f).read()
      d = data.split('orig')
      print 'new'.join(d)
"
(replace "print..." with "open(f, 'w').write('new'.join(d))" to replace in 
files)

This is more verbose than a "find (only files) | sed -i s/orig/new/", but it 
saves me from having to escape all kind of weird stuff in sed... 

Note: Until today I haggled with sed instead, because I didn't think this 
would be that easy with python... 

> This is what UNIX -- and for me at least, also the Hurd -- is really all
> about.

But it's only useful to people who often have to do these kinds of tasks. 

Just look at the viewpoint of a writer instead. He needs to be able to write 
text and sometimes replace some words in a list of files. 

Learning the intricacies of cat and sed won't help him - he will lose far more 
time than he wins, since he can just use a script which does what he needs to 
do - or get someone to write it for him. 

It's far less versatile than the shell, but it does what he needs and he 
doesn't have to spend as much time learning things he won't really need 
(improving ones writing skills takes enough learning time). And he doesn't 
have to keep all the different programs and options in mind. 

In short: A specialized script helps him to stay focussed on his work. 

Best wishes, 
Arne

--- --- --- --- --- --- --- --- --- 
Unpolitisch sein
heißt politisch sein, 
ohne es zu merken. 
- Arne (http://draketo.de)
--- --- --- --- --- --- --- --- --- 

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]