[Top][All Lists]

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

Re: OT: automation

From: olafBuddenhagen
Subject: Re: OT: automation
Date: Sun, 1 Nov 2009 13:17:27 +0100
User-agent: Mutt/1.5.19 (2009-01-05)


On Thu, Oct 29, 2009 at 08:34:50AM +0100, Arne Babenhauserheide wrote:
> Am Mittwoch, 28. Oktober 2009 20:31:46 schrieb Sergiu Ivanov:

> The scripts I mean are these small utilities which can do what I need - and 
> exactly that. 
> Example: 
>       - babsearch_n_replace.py [options] "orig str" "new str" file1 dir1 
> file2 file3
> It has two additional (relevant) options: 
>       --dry-run -> don't change anything
>       --suffixes='<.txt,.html>' - comma-seperated list of suffixes to act on. 

I think that already hints at the problem: while such tools are trivial
enough for the really simple use cases (e.g. "zmv '*.JPG' '*.jpeg'"),
there is always a drift towards adding more and more features, to cover
additional use cases... And soon the tool becomes so complicated that
you could just as well learn the generic shell commands and get more

> (I prefix most of them with "bab", since they really are my private
> tools.

Well, I do have some private scripts and aliases too of course -- but
only for those things that are either too complex to type them each time
(or to put them on a single line so that I can recall them from shell
history), or things that I use *really* often. For example I used to do
my Google and LEO searches by hand:

   netrik google.com/search?q=foo+bar
   netrik dict.leo.org?search=foo+bar

(Usually just recalling them from history and only replacing the actual
search terms of course.)

Only once I knew them by heart -- and thus it would have no further
educational value to continue doing them by hand -- I created aliases
(or actually shell functions te be exact):

   leo() { netrik dict.leo.org?search="$*"; }
   go() { netrik google.com/search?q="$*"; }

This way I still know how to do them by hand when I don't have my
aliases available.

Things like renaming multiple files, or global search and replace, do
not fall in either of the categories mentioned above: they are trivial
enough to type them out (or recall from history), and I don't need them
often enough that I'd consider them candidates for creating aliases.

> > Hm, this may be case-specific :-) For me the sed command is much
> > easier :-)
> I think it might be "Python feels like home for me"-specific ;) 

Which just proves my point really: generic knowledge beats more specific
tools :-) You prefer Python over sed, even though it's more complicated
to accomplish certain tasks, because you can use the Python knowledge
for more things. And for the very same reason shell scripting is better
than specific tools most of the time.

> Might be related to having many spaces and non-letter characters in
> filenames, since the OS and tools damn well should not restrict how I
> name my files :)

It shouldn't, and it doesn't. But that doesn't mean it's a good idea to
make use of this possibility...

In the same vein, you could argue that a programming language should not
restrict characters you can use in an identifier -- and indeed some
languages (PHP being one of them IIRC) allow pretty much everything in
identifies, including spaces. Still it's not very wise to use such
identifiers. Just use underscores and profit.


reply via email to

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