LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-29-2014, 01:07 PM   #1
stevenjeffries
LQ Newbie
 
Registered: Sep 2014
Posts: 2

Rep: Reputation: Disabled
Help using cat command.


Hello everyone.

I know there should be a simple way to do this, but I'm having a hard time finding this online.

Let's say that I have a directory with a bunch of text files, and I want to cat them all together.
Code:
cat *.txt > output.txt
does the job, but there aren't new line characters at the end of each of these text files, so the last line of each file is merged with the first line of the next file.

My question: how do I cat a group of files together, but throw a new line character between each file?
 
Old 09-29-2014, 01:15 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,208

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
I would think the easiest way would be to add the newline to each file, then go about catting them normally.

Code:
sed -i -e '$a\' *.txt
 
Old 09-29-2014, 05:19 PM   #3
stevenjeffries
LQ Newbie
 
Registered: Sep 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
That works for me, thanks szboardstretcher,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cat command -s , -n doug skillmore Linux - Newbie 2 02-27-2013 04:52 PM
Cat command Option foysol_bgd Linux - Newbie 5 12-11-2008 10:33 AM
CAT Command ouncya Linux - Newbie 11 08-25-2007 11:48 PM
cat command juanb Linux - Newbie 4 08-19-2004 11:14 AM
cat Command Moeses Linux - General 1 06-20-2002 03:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration