srtipping chars from filenames...

Mark Newton newton at atdot.dotat.org
Wed May 21 13:49:00 CST 2003


On Wed, May 21, 2003 at 01:39:43PM +0930, Daniel A Moore wrote:

 > #!/bin/sh
 > # Shifty behaviour
 > 
 > 
 > echo $temp
 > 
 > while [ $# -ne 0 ]
 > do
 >         filename=$1
 >         oldfilename=$1
 >         filename=`echo $filename | tr ':' '_'`
 >         export filename
 >         export oldfilename

What are these two lines intended to achieve?

 >         mv $oldfilename $filename
 >         shift
 > 
 > done
 > echo
 > exit 0

Looks far too complicated.  Use this instead.

    #!/bin/sh -
    for f in $*; do
        mv $f `echo $f | tr : _`
    done

There's a world shortage of keystrokes;  you should conserve them 
wherever you can. :-)

  - mark


--------------------------------------------------------------------
I tried an internal modem,                    newton at atdot.dotat.org
     but it hurt when I walked.                          Mark Newton
----- Voice: +61-4-1620-2223 ------------- Fax: +61-8-82231777 -----

-- 
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.freenode.net
To unsubscribe from the LinuxSA list:
  mail linuxsa-request at linuxsa.org.au with "unsubscribe" as the subject



More information about the linuxsa mailing list