Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Concatenating 3 files into a single file

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-28-2013
Codesearcher Codesearcher is offline
Registered User
 
Join Date: Apr 2009
Last Activity: 5 August 2013, 10:56 AM EDT
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Concatenating 3 files into a single file

I have 3 files
File1

Code:
C1 C2 c3

File 2

Code:
C1 c2 c3

File 3

Code:
C1 c2 c3

Now i want to have
File1 as
Code:
C1 c2 c3 I

File2 as
Code:
C1 c2 c3 O

File3 as
Code:
c1 c2 c3 D

and these 3 files should be concatenated into a single file
how can it be done in unix script?

Last edited by Scrutinizer; 01-28-2013 at 09:43 AM.. Reason: code tags
Sponsored Links
    #2  
Old Unix and Linux 01-28-2013
posix's Unix or Linux Image
posix posix is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 30 March 2016, 3:58 AM EDT
Location: grep "Bhubaneswar" "india"
Posts: 192
Thanks: 8
Thanked 13 Times in 13 Posts
Please elucidate your data, for concatenate you can try paste command. Please use your delimeter as per your wish with -d option

Code:
paste  temp1.txt temp2.txt temp3.txt > temp4.txt

Sponsored Links
    #3  
Old Unix and Linux 01-28-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 7 December 2016, 11:24 PM EST
Location: Amsterdam
Posts: 11,104
Thanks: 440
Thanked 3,111 Times in 2,751 Posts
Try:

Code:
awk '{print $0,I}' I=I file1 I=O file2 I=D file3

    #4  
Old Unix and Linux 01-28-2013
tokiwinter tokiwinter is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 28 January 2013, 9:48 AM EST
Location: Melbourne, Australia
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
The case of the data in your source files and expected output does not match. Is this intentional?
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Concatenating Files In A Year/Month/Day File Structure Grizzly Shell Programming and Scripting 3 09-11-2009 08:50 AM
Concatenating column values with unique id into single row jsaravana Shell Programming and Scripting 17 08-26-2009 11:00 AM
Concatenating two files Sriramprabu Shell Programming and Scripting 6 09-16-2008 12:33 AM
concatenating x files into a one... Nicol UNIX for Dummies Questions & Answers 1 09-30-2004 09:13 AM



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