Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-28-2013
Registered User
 
Join Date: Apr 2009
Posts: 35
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 08:43 AM.. Reason: code tags
Sponsored Links
    #2  
Old 01-28-2013
posix's Avatar
Registered User
 
Join Date: Feb 2010
Location: grep "Bhubaneswar" "india"
Posts: 184
Thanks: 7
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 01-28-2013
Scrutinizer's Avatar
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,341
Thanks: 144
Thanked 1,754 Times in 1,591 Posts
Try:

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

    #4  
Old 01-28-2013
Registered User
 
Join Date: Jan 2013
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:50 AM
Concatenating column values with unique id into single row jsaravana Shell Programming and Scripting 17 08-26-2009 10:00 AM
Concatenating two files Sriramprabu Shell Programming and Scripting 6 09-15-2008 11:33 PM
concatenating x files into a one... Nicol UNIX for Dummies Questions & Answers 1 09-30-2004 08:13 AM



All times are GMT -4. The time now is 09:34 AM.