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

Ag. Hatzimanikas a.hatzim at gmail.com
Thu Feb 22 06:47:35 PST 2007


On Thu, Feb 22, at 11:01 Warren Head wrote:
> 
> Some files however are still unix syntaxed files, but because the last line
> of the file is (somehow no longer) empty, this last line is no longer
> executed by the DBMS.
>

At a first step,to determine the reason,can you show us the output of
a problematic file,plus a working file with:

cat -A file |tail -n 2

Simon Geard wrote:
>
> I guess what we're looking for is a list of files for which the
> last character of the file is a LF. Not sure how you'd do that, since
> grep would presumably just ignore LF characters - you can't exactly 
> match on them, can you?
>
Simon,

cat is able to display these kind of symbols,included the end of
line character as ($) with the -E switch and the tab character as (^I) with the
-T switch.
Then it's a matter of cat'ing the file and feed it to sed.
cat -E $filename| sed '$!d;/$/!d'

What I want to see from Warren and in a way that also would be beneficial for 
the list,is to translate the human logic to actions and code.
Here is what I am thinking.

<human_logic>
find the files in this directory with suffix let's say *.sql and do for them:
if one of these has: 
first (a) condition and maybe a second condition (b) etc ...
then do: the (A) *action* and possible a (B) action ect ...
otherwise (else) do: (C) action,or continue, or exit
</human_logic>

Then we can translate the above paragraph to a snippet of code and do the job.

That way,I believe Warren himself can find the solution not only for
this problem but for the others will come.



More information about the blfs-support mailing list