Click to See Complete Forum and Search --> : how do i convert a bunch of file at once?


pbharris
02-22-2001, 07:00 PM
hi all,
i have a utility called 'dos2unix' which strips the newline char which gets sent in with dos type files. I have a bunch of directories full of these files. The file commands is called like this:

dos2unix input output
When using it one file at a time I have output be the same name as input, e.g.
dos2unix hullo.c hullo.c

I started this then quickly realized i had no idea of how to read a directory (or a file) into a shell script:

#! /bin/sh
if
somthing needs to go here
dos2unix $n $n
fi

jemfinch
02-22-2001, 07:47 PM
I don't use dos2unix. I would just do this:

perl -pi -e 's/\r\n/\n/' file1 file2 file3

Jeremy

error27
02-22-2001, 11:29 PM
maybe something like this?

for i in * ; do dos2unix $i $i ; done

(run that at the comandline to change all your files to unix style)

pbharris
02-23-2001, 12:43 AM
thanks people!!!