LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 11-19-2008, 03:38 PM   #1
chips11
LQ Newbie
 
Registered: Nov 2008
Posts: 13

Rep: Reputation: 0
Question Command to join text files with headers


I am trying to join two tab delimited text files using the command

usr/bin/join /home/user/file1.txt /home/user/file2.txt > /home/user/file3.txt

But even though it creates the new file text3.txt, the file is empty, 0kb,

The text files have the exact same columns with header rows and I want to take the two files, and join them, or concatenate them, leaviing just the one header row.

I am hoping someone may know how to do this....
 
Old 11-19-2008, 03:42 PM   #2
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by chips11 View Post
I am trying to join two tab delimited text files using the command

usr/bin/join /home/user/file1.txt /home/user/file2.txt > /home/user/file3.txt

But even though it creates the new file text3.txt, the file is empty, 0kb,

The text files have the exact same columns with header rows and I want to take the two files, and join them, or concatenate them, leaviing just the one header row.

I am hoping someone may know how to do this....
cat file1 file2 >file3
--edit--
taking headers into account:
Code:
cp file1 file3
tail +2 file2 >> file3

Last edited by ErV; 11-19-2008 at 03:44 PM.
 
Old 11-19-2008, 04:33 PM   #3
chips11
LQ Newbie
 
Registered: Nov 2008
Posts: 13

Original Poster
Rep: Reputation: 0
empty file

Thankyou, For some reason the same is happening with the cat command as was with the join. A new file (file3) is being created, but it is empty, even though file1 and 2 are several mb.

I tried the cp, but I think for what I am doing it may not be ok as the process will repeat regularly and I think copy would end up with a adding the new files to the ones created when last run. When each time it runs I want to create a new file.
 
Old 11-19-2008, 04:43 PM   #4
chips11
LQ Newbie
 
Registered: Nov 2008
Posts: 13

Original Poster
Rep: Reputation: 0
agh...it appears it was just because i was putting usr/bin and did not need to. I thought I always had to put that before a command...

Thanks so much for your help, especially with the headers, this will save me so much time
 
  


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
Unable to join domain using Net Join command in FC3 client jeb083079 Linux - Networking 9 07-30-2007 03:41 AM
Command to select and move mutiple files from list in text file steve.paris Linux - Newbie 11 11-27-2005 01:44 PM
cat command for text files minm Linux - Newbie 5 07-03-2005 01:32 AM
Command line tools to Find files with specific text naps Linux - Software 5 11-15-2004 05:46 AM
Adding headers to text files Madrinator Linux - General 1 04-21-2004 07:46 PM


All times are GMT -5. The time now is 10:33 AM.

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