The UNIX and Linux Forums  

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


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
On comparing two number getting error,not able to rectify it pplease help moh_hak_786 Shell Programming and Scripting 2 06-24-2007 08:55 PM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 07:10 AM
SSH Problem auth problem budrito UNIX for Advanced & Expert Users 1 03-17-2004 07:12 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-21-2005
Registered User
 

Join Date: Sep 2005
Posts: 130
Question please rectify my problem

Dear Friends,

I have two data file containing 4 coloums.

my first file has data like this

ex:
file1:
2.56 66.82 ***
2.56 66.82 ***
2.54 66.84 ***
2.54 66.84 ***
2.51 66.84 ***
2.51 66.84 ***
2.51 66.86 ***
2.49 66.86 ***
2.47 66.86 ***
2.45 66.84 ***
2.44 66.86 ***

and second file having the data like this

2.56 66.82 24.2
2.56 66.82 23.6
2.54 66.84 22.1
2.54 66.84 28.1
2.51 66.84 72.3
2.51 66.84 ***
2.51 66.86 ***
2.49 66.86 ***
2.47 66.86 ***
2.45 66.84 ***
2.44 66.86 ***

now my problem starts

now i want to add second file last coloum to my first file as a last coloum .

in both files first two coloums are same.

now how to add second file last coloum to first file as a last coloum

I think awk can solve my problem.

but i dont know how to write it.

please help me


thanks & regards
rajan


Reply With Quote
Forum Sponsor
  #2  
Old 12-21-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
It is just a matter of cut and paste.
Code:
cut -d' ' -f3 file2.lst | paste file1.lst -
Reply With Quote
  #3  
Old 12-21-2005
Registered User
 

Join Date: Sep 2005
Posts: 130
dear friend,

your code has not working
Reply With Quote
  #4  
Old 12-22-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
"not working" does not explain the error. What is the error that you are getting? Post the command that you are running, the output that you are getting and the output that you expect.
Reply With Quote
  #5  
Old 12-22-2005
vishnu_vaka's Avatar
Registered User
 

Join Date: Nov 2005
Location: Hyderabad
Posts: 7
cut -d' ' -f3 2.txt |paste 1.txt -


2.56 66.82 *** 24.2
2.56 66.82 *** 23.6
2.54 66.84 *** 22.1
2.54 66.84 *** 28.1
2.51 66.84 *** 72.3
2.51 66.84 *** ***
2.51 66.86 *** ***
2.49 66.86 *** ***
2.47 66.86 *** ***
2.45 66.84 *** ***
2.44 66.86 *** ***


the above command gives the result u desired

Last edited by vishnu_vaka; 12-22-2005 at 01:22 AM.
Reply With Quote
  #6  
Old 12-22-2005
Registered User
 

Join Date: Sep 2005
Posts: 130
Thank u vishnu_vaka your script is working fine.

please provide solution to this problem also.

after running the above script the output is like this.


2.56 66.82 *** 24.2
2.56 66.82 23.6 23.6
2.54 66.84 23.6 22.1
2.54 66.84 *** 28.1
2.51 66.84 *** 72.3
2.51 66.84 *** ***
2.51 66.86 *** ***
2.49 66.86 *** ***
2.47 66.86 *** ***
2.45 66.84 *** ***
2.44 66.86 *** ***

Now I want to delete lines where the third coloum has no data.
ie I want the data where the third coloum has not null.

like this
2.56 66.82 23.6 23.6
2.54 66.84 23.6 22.1

how to get this

please help

regards
rajan



Reply With Quote
  #7  
Old 12-22-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
vishnu_vaka's code is the same as what I had posted. I still cannot get how you got an error while running it. But to answer your last question,
Code:
cut -d' ' -f3 <name of second file> | paste <name of first file> -|awk '$3 !~ /\*\*\*/ {print}'
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0