[svlug] rename

Nathan Myers ncm at cantrip.org
Wed Apr 21 18:49:52 PDT 1999

Dave Zarzycki <dave at loki.sbay.org> wrote:
> Robert Hajime Lanning wrote:
>>Dave Zarzycki <dave at loki.sbay.org> wrote:
>>>   $ export name=`echo HELLO|tr [A-Z] [a-z]`
>>>   $ echo $name
>> This forks off 3 processes just to set 1 variable.
> Agreed. This is very slow, but nobody ever promised that shell scripting
> was fast either. If I care about speed, I write the program in C.

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
does matter, and a shellscript is plenty fast enough if not hobbled.
To fork off separate programs for each file name would make a reasonable 
shellscript into an unreasonable one.

If you needed to do this, you might try something like this before
jumping for the C compiler:

  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

It's better, though, to have shell function for the purpose.
Maybe that's why Perl got popular.  I suspect most Perl programs
do things that wouldn't get done if it would otherwise take a C 
program to do the job.

Nathan Myers
ncm at cantrip.org

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