finding files in dos format + .sql files without an empty last line

Warren Head warrenhead at gmail.com
Wed Feb 21 03:39:03 PST 2007


2007/2/21, Ag. Hatzimanikas <a.hatzim at gmail.com>:
>
> On Wed, Feb 21, at 10:14 Warren Head wrote:
>
>
> This simple loop should do the job,checked in bash/zsh.
> ===========================================
> for filename in $(find . -type f);do
>         if [[ -n $(file $filename |grep CRLF) ]]
>         then
>         sed 's/^M$//' $filename > $filename.unix
>         fi
> done
> ===========================================


This works excellent already.
I did however forget a second issue. The final line in the files I am
worried about has to be an empty line.
These are actually .sql files. The DBMS will not execute the last line, even
if it has text in it. (Regardless of whether they are
(now) written in a unix format.)

But thanks sofar anyways!

Cheers, Warren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfromscratch.org/pipermail/blfs-support/attachments/20070221/feb022d6/attachment.html>


More information about the blfs-support mailing list