Date: Thu, 30 Mar 2006 12:26:38 -0500 (EST) From: Jerry McAllister <jerrymc@clunix.cl.msu.edu> To: vaaf@broadpark.no (Vaaf) Cc: questions@freebsd.org Subject: Re: ASCII files becoming double lined Message-ID: <200603301726.k2UHQcrJ006300@clunix.cl.msu.edu> In-Reply-To: <7.0.1.0.2.20060330174336.020d6a18@broadpark.no>
next in thread | previous in thread | raw e-mail | index | archive | help
>
> At 17:20 30.03.2006, Jerry McAllister wrote:
> > >
> > >
> > > Hello!
> > >
> > > Sometimes I notice ASCII files becoming double lined.
> > > As in there somehow appearing an empty line in between every line.
> > >
> > > Why is this? And:
> > >
> > > 01 How can I detect files with double lines?
> > > 02 And then eliminate this double lining?
> >
> >Check out tr(1)
> >It will quite easily remove the extra CR in every line.
> >Then, if you need, you can rename the clean file to the dirty file
> > something like: # tr -d "\r" < dirtyfile > cleanfile
> > # mv cleanfile dirtyfile
> >
> >Sorry, it takes two steps.
> >Thre are other methods that do it without a second file, but
> >for newbies, this is easier to understand.
> >
> >////jerry
> >
> > >
> > > The goal would be to apply 01 and 02 to this script:
> > >
> > > #!/usr/local/bin/bash
> > > #
> > > # Remove CRLF, trailing whitespace and blank lines.
> > > # $MARBEJA: clean.sh,v 1.0 2007/11/11 15:09:05 awad Exp $
> > > #
> > >
> > > for file in `find -s . -type f`; do
> > >
> > > if file -b "$file" | grep -q 'text'; then
> > >
> > > echo >> "$file"
> > >
> > > tr -d '\r' < "$file" \
> > > | sed -E -e 's/[[:space:]]+$//' \
> > > | cat -s - > "${file}.tmp" && mv -f "${file}.tmp" "$file"
> > >
> > > echo "$file: Done"
> > >
> > > fi
> > >
> > > done
> > >
> > > Thanks,
> > > Vaaf
> > >
>
> Thanks Jerry! But isn't this what my script already does?
Guess so. I didn't read that
////jerry
>
> As for Mr. Kennaway, if you had a big bugger up your nose the minute
> you're about
> to go on a date, wouldn't you like an honest opinion?
>
> Vaaf
>
>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603301726.k2UHQcrJ006300>
