Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Did you try 'file -i' for figuring out file types?
"...If you want to build a ship, don't drum up people together to collect
wood and don't assign them tasks and work, but rather teach them to long
for the endless immensity of the sea." -- Antoine de Saint-Exupery
;):):-):):-):):-)8')
Michael McGlothlin <EMAIL:PROTECTED>
http://kavlon.org/projects/
On Wed, 2 Oct 2002, Mark Rages wrote:
> On Wed, Oct 02, 2002 at 04:26:05PM -0500, Mike Miller wrote:
> > I know of four different formats for text files:
> >
> > source: http://ddl.jpl.nasa.gov/ddl/purpose/multiplat.pdf
> >
> > IBM PC
> > This is a line of text.<CR><LF>
> > Macintosh
> > This is a line of text.<CR>
> > UNIX workstation
> > This is a line of text.<LF>
> > VAX/VMS workstation
> > <LENGTH>This is a line of text.*
> >
> > * This is the most common format supported under VMS.
> >
> >
> > Which creates a crazy situation where I work because all four of these OSs
> > are used here. My most common problem is that I have IBM PC text files on
> > a Unix machine. This isn't a terrible problem because we have dos2unix to
> > convert files. On Solaris, I'd deal with it like this...
> >
> > dos2unix -ascii originalfile convertedfile ; mv convertedfile originalfile
>
> On my machine dos2unix will convert files in place if only passed one
> filename.
>
> >
> > ...but who wants all that hassle? How about something that works like
> > this?:
> >
> > d2u filename
> >
> > Or better, something that can work with a list of filenames:
> >
> > d2u a* www/bobstuff/*
> >
> > So we could write a script. I think perl can do this pretty efficiently
> > so that we could avoid dos2unix and writing temp files. What do you
> > think?
> >
> > It seems to me that this does what we want for an individual text file:
> >
> > perl -pi -e 's/\015$//' filename
> >
> > Is there an easy way to make this into a script that will take filenames
> > (possibly with wildcards) as input? It would be nice if it would work
> > with wildcards exactly as ls works with them.
> >
> > Mike
>
> Well, based on your description, it would just be a small trick to
> heuristically determine the input file format.
>
> Then you would need a switch to determine output format. Or look at
> argv[0] and react accordingly, a la busybox.
>
> Binary files should be left unmolested unless a special binary switch is
> used. (because these conversions are irreversible for binary files!)
>
> It would be impossible to write such a utility in Perl due to its limited
> flexibility and horrific syntax*
>
> Regards,
> Mark
>
> *Note to Mike: This inflammatory statement is included to induce the Perl
> geeks to immediately open vi and start coding...
>
>
> --
> To unsubscribe, go to http://mlug.missouri.edu/members/edit.php
>
> Archives are available at http://mlug.missouri.edu/list-archives/
>
--
To unsubscribe, go to http://mlug.missouri.edu/members/edit.php
Archives are available at http://mlug.missouri.edu/list-archives/