On Tue, Mar 21, 2000 at 08:08:19PM +1000, Steve Youngs wrote:
> Hey People
> 
> I'm having a problem with a bash shell script that I'm hoping someone
> here can help me with.
> 
> The script is supposed to convert ^M to ^J in all the files in a
> directory.  The script is invoked with 'scriptname *'.  The thing that
> I just can't nut out is how to increment the variable that represents
> the filename.
> 
> Here's what I have..
> 
> 
> I know the answer will be something really simple and easy, I just
> can't think of it. :-(
> 
shift. :-) (info bash C-s shift C-s)
also cat $FILE | tr lalal > $FILE
will break. probably you want this:
=============cut=================
#! /bin/bash

LOOP_TIMES=$#
LOOP=1
FILE=$1
TMPFILE=$(mktemp /tmp/tmp.XXXXX)
if [ $? != 0 ]
then
        echo "Couldn't get temp file"
        exit 1
fi

while [ $LOOP -le $LOOP_TIMES ]; do
        cat $FILE | tr "\r" "\n" > $TMPFILE
        mv $TMPFILE $FILE
        shift
        LOOP=$[ LOOP + 1 ]
done        
============end=================

have fun,

greg
-- 
dronf!

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs

Reply via email to