The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find a file and xarg mv to append date to file jacktravine SUN Solaris 6 10-05-2009 12:27 PM
gzip a file and append creation date stamp to file jacktravine SUN Solaris 3 09-22-2009 11:09 AM
how to append file contents at server1 to another file in server2 aemunathan Shell Programming and Scripting 2 06-16-2009 06:35 AM
Trying to empty file using > but the file size increasing when next append firdousamir UNIX for Dummies Questions & Answers 4 06-23-2008 04:37 AM
Append a field to the end of each line of a file based on searching another file. ultimate Shell Programming and Scripting 2 03-29-2005 11:21 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-27-2009
Muhammad Rahiz Muhammad Rahiz is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 12
Append file

Hello all,

I require assistance in combining files.
This is the scenario: I've got lots of files which contain one column in each file and would like to combine the files into one so that the contents of the file can be sorted.

For example,

File 1 File 2 ...
a d
b e
c f

Desired output;

File 3
a
b
c
d
e
f

I tried paste/cat but the output (as follows) is not what I wanted)

File 3
a d
b e
c f

Any suggestions?

Thanks.
  #2 (permalink)  
Old 10-27-2009
the_red_dove the_red_dove is offline
Registered User
  
 

Join Date: Aug 2009
Location: California
Posts: 23
This always works for me Give it a shot
cat file1 file2 >> file3
  #3 (permalink)  
Old 10-27-2009
Muhammad Rahiz Muhammad Rahiz is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 12
Thanks red dove!

I just found out that it works using 'cat'.

cat file1 file2 > file 3 # appends content of the files in a single column

Paste however, appends contents by column.

paste file1 file2 > file 3
  #4 (permalink)  
Old 10-27-2009
the_red_dove the_red_dove is offline
Registered User
  
 

Join Date: Aug 2009
Location: California
Posts: 23
I don't recommend cut/paste. That screws up files sometimes if the files have ascii ending characters at the end of line
  #5 (permalink)  
Old 10-27-2009
deindorfer deindorfer is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 9
Pls. Delete

Last edited by deindorfer; 10-27-2009 at 06:35 PM..
  #6 (permalink)  
Old 10-27-2009
Scrutinizer Scrutinizer is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 761

Code:
$> cat file1
a
b
y
r
i
d
c

$> cat file2
d
e
f

$> cat file3
g
h
l


Code:
$> sort file[123]
a
b
c
d
d
e
f
g
h
i
l
r
y


Last edited by Scrutinizer; 10-28-2009 at 03:13 AM..
  #7 (permalink)  
Old 10-28-2009
the_red_dove the_red_dove is offline
Registered User
  
 

Join Date: Aug 2009
Location: California
Posts: 23
@scrutinizer: Sure, there are several different ways to get that done, I just suggested most basic solution, which works with any shell/ any flavor.

@deindorfer: What are you suggesting to delete? The thread itself? Or the suggestions?
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0