Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Feb 2006 22:42:50 +1100
From:      Norberto Meijome <freebsd@meijome.net>
To:        Kristian Vaaf <vaaf@broadpark.no>
Cc:        questions@freebsd.org
Subject:   Re: How to ensure one blank line on top of ASCII files?
Message-ID:  <43F070BA.1000205@meijome.net>
In-Reply-To: <7.0.1.0.2.20060213094752.021a8eb0@broadpark.no>
References:  <7.0.1.0.2.20060213094752.021a8eb0@broadpark.no>

next in thread | previous in thread | raw e-mail | index | archive | help
Kristian Vaaf wrote:
> 
> Hello!
> 
> I need to make sure all my ASCII files start with one blank line.
> 
> I just need to know what command to use,
> I've written the rest of the script to do this for me:
> 
> -- 
> 

echo "" > MY_BLANK_LINE.txt

> for file in `find -s . -type f -not -name ".*"`; do
> 
>     if file -b "$file" | grep -q 'text'; then
> 

	mv $file $file.tmp
	cat MY_BLANK_LINE.txt $file.tmp >> $file
	rm -f $file.tmp	

>         echo "$file: Done"
> 
>     fi
> 
> done

rm -f MY_BLANK_LINE.txt


There possibly are far more elegant solutions...but that should work.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43F070BA.1000205>