[sclug] Redirecting Tail to a file preserving end of lines
Alex Butcher
lug at assursys.co.uk
Mon Jul 18 13:45:42 UTC 2005
On Mon, 18 Jul 2005, Sapan Ganguly wrote:
> On 7/18/05, Dickon Hood <sclug at splurge.fluff.org> wrote:
>> On Mon, Jul 18, 2005 at 14:18:35 +0100, Sapan Ganguly wrote:
>> : how do I take the last line of a bunch of files and put them into a
>> : new file? This is what I have been trying -
>>
>> : # tail --lines=1 --silent *.csv >> newfile
>>
>> : For some reason the end of lines aren't preserved, newfile ends up
>> : being one really long line.
>>
>> for i in *.csv; do tail -1 $i; done > newfile
>>
>> Works for me.
> Thanks for your reply but I tried that too and it still becomes one
> long line in the new file.
Oops! So it does. Dickon's approach will only work if the files end with a
LF (0x0a) character. Can you arrange for this to be the case? If not, you'll
have to go with my approach. Test it thoroughly before relying upon it.
>> Dickon Hood
Best Regards,
Alex.
--
Alex Butcher Brainbench MVP for Internet Security: www.brainbench.com
Bristol, UK Need reliable and secure network systems?
PGP/GnuPG ID:0x271fd950 <http://www.assursys.com/>
More information about the Sclug
mailing list