On 2/23/07, Ag. Hatzimanikas <[EMAIL PROTECTED]> wrote:
> On Fri, Feb 23, at 09:11 Warren Head wrote:
>
> Here what I came up quickly (untested).
>
> Test1.Don't look for files with an empty last line.
> [[ -n $(sed '$!d' $filename) ]]
> Test2,take the last character.
> lastcharacter=$(cat -A $filename |sed '$!d;s/.*\(.\)$/\1/')
>
> Now constatanate them.
>
> if [[ -n $(sed '$!d' $filename) ]] && [[ ! "$lastcharacter" == "\$" ]];then
> sed -i '$G' $filename
> fi
>
> I maybe missing something obvious here so please correct me.
An alternative:
if cat -E $file | tail -n1 | grep -q '[^$]$'; then
echo "No line feed at end of $file"
echo >> $file
fi
Seemed to work in my test over here.
--
Dan
--
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page