![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
It is just a matter of cut and paste.
Code:
cut -d' ' -f3 file2.lst | paste file1.lst - |
|
#3
|
|||
|
|||
|
dear friend,
your code has not working |
|
#4
|
||||
|
||||
|
"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.
|
|
#5
|
||||
|
||||
|
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. |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
||||
|
||||
|
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}'
|
||||
| Google The UNIX and Linux Forums |