On Wed, Feb 21, at 12:39 Warren Head wrote:
> 2007/2/21, Ag. Hatzimanikas <[EMAIL PROTECTED]>:
> >
> >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.
Then add a second test to check if there is an empty line.
This should be enough.
&& [[ -z $(sed '$!d' $filename) ]] ;then ...

Where -z means that the condition is true if the length of the string is zero.
In our case if the last line is empty the condition will be true and then 
the sed that will remove the <CR><LF> line terminators will be executed.

Check the bash man page for CONDITIONAL EXPRESSIONS.
-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to