Add a Couple of Carriage returns to text file

I have a directory of over a hundred text files that I'm getting ready to merge with the CAT command. However there is only one space after each file; this makes the output look crowded.

I would like to add two, possibly even four carriage returns at the end of each text file to make the final product a bit more readable.

I checked out another thread about this but the solution didn't work for me; I got a "bash: *.txt: ambiguous redirect"

Yes I had a cloudy moment where I didn't get that error message but I ate lunch with my son and came back to the problem and it made a whole lot more sense.

So I then tried a couple of other options where I specified the output but can't quite get the line carriage solution.

Thanks for any help you might give.

~ ~

P.S. If you are interested in which thread I was looking at, search this forum for "add-carriage-return-end-file". It'll come up as the first post (sorry the system doesn't allow me to post links yet) :slight_smile:

---------- Post updated at 07:58 PM ---------- Previous update was at 03:28 PM ----------

Ok never mind ... Hope this helps someone else but I managed to dig around and try many many different variances until one worked. This is what did it for me.

Let me know if you can think of any improvements or anything that I'm overlooking.

sed -i '$ s/$/ \r\r/' *

Those are carriage returns, not line feeds, which seem pretty "Apple"; UNIX uses linefeed. I did not know sed $ fired for every file, not just for the last. Mine does not. A shell script does this easily:

for f in *
do
 cat $f
 echo
 echo
 echo
done

Just updating the thread in hopes that it might be useful for someone else in the future.

I'm using Ubuntu Lucid and fired off this SED on a typical BASH CLI.

I had about 60+ text files and it whipped right through them. Can't tell you what the text files were originally created on (since I didn't make them). I just wanted to combine them so I could have a single "text book" which I could move to my phone's ebook reader.

Thanks.