[svlug] rename

David E. Fox dfox at belvdere.vip.best.com
Wed Apr 21 19:23:47 PDT 1999

> Nonsense.  When was the last time you wrote a C program to rename
> files?  When you have to run through thousands of file names, speed

Hmm. Early on in my use of Unix, I was faced with a situation where
I had to lowercase a whole slew of filenames and strip the extra
DOS linefeed characters. I got some help in simple scripting
really fast, and since my own experience up to that point had been
mostly DOS, I was *amazed* you could do stuff like:

for i in `ls` 
mv $i | `echo $i | tr [A-Z] [a-z]`

without needing a C program. And I didn't want to have to write a
C program to do that -- besides, I didn't know how -- at least not
on Unix. And certainly I wasn't about to type in one mv command after
another, which is how most DOS people would have ended up doing it, if
they had to :).

I wasn't about to care how many processes it forks to do its job, if
I'd only need it that one time (or infrequently at best). Sure, when
you can minimize extra processes it's a good idea, which is why, for
instance you don't do:

$ cat something | more

when 'more something' will suffice.

>   generate-filenames  > /tmp/a
>   generate-filenames | tr 'A-Z' 'a-z' >> /tmp/a   # note, no '[]'
>   sort -f -o /tmp/a /tmp/a
>   cat /tmp/a | while read i; do read j; mv $i $j; done

That is likely to cause more work than the shell script I 
> It's better, though, to have shell function for the purpose.
> Maybe that's why Perl got popular.  I suspect most Perl programs

Perl probably got powerful because for many things it was seen as
a cleaner way, and one didn't have to pipe as many things back
and forth to sed/awk/sort/tr and friends.

> Nathan Myers
> ncm at cantrip.org
David E. Fox                 Tax              Thanks for letting me
dfox at belvdere.vip.best.com   the              change magnetic patterns
root at belvedere.sbay.org      churches         on your hard disk.

echo "unsubscribe svlug" | mail majordomo at svlug.org
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to unsubscribe
see http://www.svlug.org/mdstuff/lists.shtml for posting guidelines.

More information about the svlug mailing list