![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ascending order within text | kerpm | Shell Programming and Scripting | 5 | 08-15-2008 09:39 AM |
| Display modified files in ascending order | balareddy | UNIX for Advanced & Expert Users | 1 | 08-13-2008 05:48 AM |
| Ascending & Descending order numbers | pravani1 | Shell Programming and Scripting | 6 | 06-03-2008 07:43 AM |
| use of sed over cat to merge files | miwinter | UNIX for Advanced & Expert Users | 2 | 11-28-2007 01:36 PM |
| Sort / ascending order | gyik | UNIX for Dummies Questions & Answers | 1 | 03-05-2001 10:08 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
merge two files in ascending order
Hello Friends,
I want to merge two files in ascending order on the first field. And if the first field matches sort on 3rd field i.e, TXADDR should come ahead of RXADDR . file1 Code:
9 : TXADDR : 00000000
65 : TXDATA 0000000000000011
83 : TXDATA 0000000000000012
453 : TXADDR : 00000000
509 : TXDATA 0000000000000001
527 : TXDATA 0000000000000002
879 : TXADDR : 00000020
934 : TXDATA 0000000000000011
953 : TXDATA 0000000000000012
971 : TXDATA 0000000000000013
Code:
9 : RXADDR : 00000001
65 : RXDATA 0000000000000011
83 : RXDATA 0000000000000012
102 : RXDATA 0000000000000013
453 : RXADDR : 00000000
509 : RXDATA 0000000000000001
527 : RXDATA 0000000000000002
546 : RXDATA 0000000000000003
879 : RXADDR : 00000020
934 : RXDATA 0000000000000011
953 : RXDATA 0000000000000012
971 : RXDATA 0000000000000013
990 : RXDATA 0000000000000014
Code:
sort -n file1 file2 > file3 So in my case the output should be Code:
9 : TXADDR : 00000000
9 : RXADDR : 00000001
65 : TXDATA 0000000000000011
65 : RXDATA 0000000000000011
Regards, user_prady Last edited by user_prady; 09-04-2008 at 12:17 AM.. |
|
||||
|
Thanks for your kind replies , but both the command outputs the same as
the command Code:
sort -n file1 file2 > file3 |
|
||||
|
Code :
Code:
sort -t":" -k1,1n -k2,2 file1 file2 Quote:
|
|
||||
|
Oh oh . I think I am misguiding you all .
Desired Output : Code:
9 : TXADDR : 00000000 9 : RXADDR : 00000001 65 : TXDATA 0000000000000011 65 : RXDATA 0000000000000011 83 : TXDATA 0000000000000012 83 : RXDATA 0000000000000012 102 : RXDATA 0000000000000013 453 : TXADDR : 00000000 453 : RXADDR : 00000000 509 : RXDATA 0000000000000001 509 : TXDATA 0000000000000001 527 : TXDATA 0000000000000002 527 : RXDATA 0000000000000002 546 : RXDATA 0000000000000003 879 : TXADDR : 00000020 879 : RXADDR : 00000020 .................... ...................... Regards, user_prady |
|
||||
|
Thanks for your reply But I want to sort reverse for the second key ..
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|