![]() |
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 |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| If Then Else Logic | jadionne | UNIX for Dummies Questions & Answers | 7 | 11-23-2007 04:27 AM |
| cannot get the logic | dineshr85 | Shell Programming and Scripting | 3 | 10-11-2007 07:34 AM |
| Strange Logic | ganesh123 | Shell Programming and Scripting | 5 | 03-20-2007 05:08 PM |
| what the logic | ramneek | IP Networking | 2 | 09-05-2005 07:42 AM |
| How do I start a program when I start my Computer? | l008com | UNIX for Dummies Questions & Answers | 1 | 06-23-2002 08:30 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
need a logic to start with awk/ sh
Hi Friends,
I got stuck where to start with .. I ve a input file like below. where I want to compare write data with my read data .. The problem is that the read data should be compared with the lastest write data on that address. Note- Both write data & read data are in the same file. TXADDR & TXDATA means -write RXADDR & RXDATA means - read Code:
120 : TXADDR : 00000000 Code:
240 : TXDATA 0000000000000001
280 : TXDATA 0000000000000002
320 : TXDATA 0000000000000003
360 : TXDATA 0000000000000004
400 : TXDATA 0000000000000005
Code:
1042 : RXADDR : 00000000 INPUT FILE Code:
120 : TXADDR : 00000000
240 : TXDATA 0000000000000001
280 : TXDATA 0000000000000002
320 : TXDATA 0000000000000003
360 : TXDATA 0000000000000004
400 : TXDATA 0000000000000005
1042 : RXADDR : 00000000
1080 : TXADDR : 00000020
1200 : TXDATA 0000000000000011
1240 : TXDATA 0000000000000012
1280 : TXDATA 0000000000000013
1320 : TXDATA 0000000000000014
1321 : RXDATA 0000000000000001
1360 : TXDATA 0000000000000015
1361 : RXDATA 0000000000000002
1401 : RXDATA 0000000000000003
1441 : RXDATA 0000000000000004
1481 : RXDATA 0000000000000005
1880 : TXADDR : 00000040
2000 : TXDATA 0000000000000021
2040 : TXDATA 0000000000000022
2080 : TXDATA 0000000000000023
2120 : TXDATA 0000000000000024
2120 : TXDATA 0000000000000025
Thanks & Regards, user_prady Last edited by user_prady; 09-01-2008 at 12:28 AM.. |
|
||||
|
Should the data always be received in the order it was sent? If so, try this:
Code:
awk '/TX/ { print $NF }' datafile > sent
awk '/RX/ { print $NF }' datafile > received
diff sent received
Last edited by Annihilannic; 09-01-2008 at 12:39 AM.. Reason: forgot the 'datafile' |
|
||||
|
Quote:
No its not like that data is not recevied until unless I specify to read exclusively . Think of as a RAM( Read access Memory) I writes to RAM by specifing TXADDR & TXDATA and I retrives the data when I specify that address with RXADDR , I get RXDATA ie, last written on that addresss. Actually Wrrtting and reading are independent of each other. Once I give TXADDR & TXDATA (5 burst - In INPUT FILE you can see five lines of input data contineously). Then after that I am going to Read those values when RXADDR comes .. Suppose I am writting to the same address twice then reading from that address then it ll read the lastest value that is written to that address. Thanks user_prady Last edited by user_prady; 09-01-2008 at 01:09 AM.. |
|
||||
|
Something like this? (not tested much)
Code:
awk '
/TXADDR/ { txaddr=$NF }
/RXADDR/ { rxaddr=$NF }
/TXDATA/ { txdata[txaddr,++txindex[txaddr]]=$NF }
/RXDATA/ {
if ($NF != txdata[rxaddr,++rxindex[rxaddr]]) {
print "rxdata " $NF " for address " rxaddr " does not match transmitted: " txdata[rxaddr,rxindex[rxaddr]]
}
}
' inputfile
|
|
||||
|
Quote:
Can You Please give a brief idea what does this statement for Code:
txdata[txaddr,++txindex[txaddr]] Regards, user_prady Last edited by user_prady; 09-01-2008 at 02:29 AM.. |
|
||||
|
Quote:
my friend Its seems to be not working for this case INFILE Code:
120 : TXADDR : 00000000
240 : TXDATA 0000000000000011
280 : TXDATA 0000000000000012
320 : TXDATA 0000000000000013
360 : TXDATA 0000000000000014
1080 : TXADDR : 00000000
1200 : TXDATA 0000000000000001
1240 : TXDATA 0000000000000002
1280 : TXDATA 0000000000000003
1320 : TXDATA 0000000000000004
2002 : RXADDR : 00000000
2040 : TXADDR : 00000020
2160 : TXDATA 0000000000000011
2200 : TXDATA 0000000000000012
2240 : TXDATA 0000000000000013
2280 : TXDATA 0000000000000014
2281 : RXDATA 0000000000000001
2321 : RXDATA 0000000000000002
2361 : RXDATA 0000000000000003
2401 : RXDATA 0000000000000004
Code:
rxdata 0000000000000001 for address 00000000 does not match transmitted: 0000000000000011 rxdata 0000000000000003 for address 00000000 does not match transmitted: 0000000000000012 rxdata 0000000000000003 for address 00000000 does not match transmitted: 0000000000000013 rxdata 0000000000000004 for address 00000000 does not match transmitted: 0000000000000014 Pls give me a suggestion .. Regards, Pradyumna |
|
||||
|
Quote:
So to cater for your second situation, all you need to do is reset the txindex[txaddr] counter to 0 each time a new TXADDR is encountered. Similarly you can reset the rxindex[rxaddr] counter each time an RXADDR is encountered. |
| Sponsored Links | ||
|
|