Re: cat * >> file-name

From: Arthur Corliss <acorliss@nevaeh-linux.org>
Date: Sat Feb 12 2005 - 22:25:08 AKST

On Sat, 12 Feb 2005, Enkidu wrote:

> I am trying to combine several text files into one using cat * >> file-name.
> Now, this works, but I need a crlf printed to the new file after every EOF of
> the files being read. Do any of you have any suggestions as to how I might
> accomplish this? I have tried echo -e "\n" >> *, but bash choked on that. Can I
> check for EOF as the files are being read? Thanks for your help,

Keep in mind that in the UNIX newlines are line feeds only, so if that's
sufficient you can simply do:

  for file in * ; do cat $file >> file-name ; echo >> file-name ; done

   -- or --

  for file in * ; do cat $file | sed '$a\\' >> file-name ; done

If you need that CrLf combo, though, you can use sed for that as well:

  for file in * ; do cat $file | sed '$a\\r' >> file-name ; done

Note that the sed statement is correct, the linefeeds are implicit due to how
sed handles lines.

        --Arthur Corliss
          Bolverk's Lair -- http://arthur.corlissfamily.org/
          Digital Mages -- http://www.digitalmages.com/
          "Live Free or Die, the Only Way to Live" -- NH State Motto
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sat Feb 12 22:25:06 2005

This archive was generated by hypermail 2.1.8 : Sat Feb 12 2005 - 22:25:06 AKST