![]() |
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. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
print all the rows from "BUY" Tag with "SELL" with Buy/sell tag at end
hi I have the following input and i want to print all the rows from "BUY" Tag till "SELL" alongwith Buy/sell tag at end of each row
Code:
------ INPUT ===== 30/06/2009,NORMAL,ALL,ALL BUY 1,CBLO/020709,T+0,30/06/2009,100.00,3.00,999835643.46,200906300000422,-, 15:04:42,BUY 2,CBLO/020709,T+0,30/06/2009,100.00,3.01,999835095.69,200906300000421,-, 15:04:42,BUY 3,CBLO/020709,T+0,30/06/2009,10.00,2.90,99984112.11,200906300000296,-, 13:32:34,BUY 4,CBLO/020709,T+0,30/06/2009,100.00,2.90,999841121.14,200906300000295,-, 13:32:34,BUY 5,CBLO/020709,T+0,30/06/2009,50.00,2.90,499920560.57,200906300000294,-, 13:32:34,BUY 6,CBLO/020709,T+0,30/06/2009,30.00,2.91,299952172.01,200906300000293,-, 13:32:34,BUY SELL 1,CBLO/020709,T+0,30/06/2009,40.00,3.24,399928998.91,200906300000038,-, 09:47:22,SELL 2,CBLO/020709,T+0,30/06/2009,50.00,3.24,499911248.63,200906300000037,-, 09:47:22,SELL 3,CBLO/020709,T+0,30/06/2009,10.00,3.24,99982249.73,200906300000036,-, 09:47:22,SELL 4,CBLO/020709,T+0,30/06/2009,100.00,3.25,999821949.52,200906300000024,-, 09:31:09,SELL 5,CBLO/020709,T+0,30/06/2009,100.00,3.25,999821949.52,200906300000023,-, 09:31:09,SELL 6,CBLO/020709,T+0,30/06/2009,100.00,3.10,999830165.83,200906300000007,-, 09:11:55,SELL 7,CBLO/020709,T+0,30/06/2009,200.00,3.10,1999660331.67,200906300000006,-, 09:11:49,SELL 8,CBLO/020709,T+0,30/06/2009,200.00,3.05,1999665809.28,200906300000002,-, 09:11:28,SELL 390.00,800.00 3899368704.98,7998622703.09 ==================================== OUTPUT ====== 1,CBLO/020709,T+0,30/06/2009,100.00,3.00,999835643.46,200906300000422,-, 15:04:42,BUY 2,CBLO/020709,T+0,30/06/2009,100.00,3.01,999835095.69,200906300000421,-, 15:04:42,BUY 3,CBLO/020709,T+0,30/06/2009,10.00,2.90,99984112.11,200906300000296,-, 13:32:34,BUY 4,CBLO/020709,T+0,30/06/2009,100.00,2.90,999841121.14,200906300000295,-, 13:32:34,BUY 5,CBLO/020709,T+0,30/06/2009,50.00,2.90,499920560.57,200906300000294,-, 13:32:34,BUY 6,CBLO/020709,T+0,30/06/2009,30.00,2.91,299952172.01,200906300000293,-, 13:32:34,BUY 1,CBLO/020709,T+0,30/06/2009,40.00,3.24,399928998.91,200906300000038,-, 09:47:22,SELL 2,CBLO/020709,T+0,30/06/2009,50.00,3.24,499911248.63,200906300000037,-, 09:47:22,SELL 3,CBLO/020709,T+0,30/06/2009,10.00,3.24,99982249.73,200906300000036,-, 09:47:22,SELL 4,CBLO/020709,T+0,30/06/2009,100.00,3.25,999821949.52,200906300000024,-, 09:31:09,SELL 5,CBLO/020709,T+0,30/06/2009,100.00,3.25,999821949.52,200906300000023,-, 09:31:09,SELL 6,CBLO/020709,T+0,30/06/2009,100.00,3.10,999830165.83,200906300000007,-, 09:11:55,SELL 7,CBLO/020709,T+0,30/06/2009,200.00,3.10,1999660331.67,200906300000006,-, 09:11:49,SELL 8,CBLO/020709,T+0,30/06/2009,200.00,3.05,1999665809.28,200906300000002,-, 09:11:28,SELL |
| Bits Awarded / Charged to r_t_1601 for this Post | |||
| Date | User | Comment | Amount |
| 07-02-2009 | Neo | added code tags and changed subject for user, cost 15000 bits | -15,000 |
|
||||
|
sory for the confusion the input and output is listed below
------ INPUT ===== Code:
30/06/2009,NORMAL,ALL,ALL BUY 1,CBLO/020709,T+0,30/06/2009,100.00,3.00,999835643.46,200906300000422,-, 15:04:42 2,CBLO/020709,T+0,30/06/2009,100.00,3.01,999835095.69,200906300000421,-, 15:04:42 3,CBLO/020709,T+0,30/06/2009,10.00,2.90,99984112.11,200906300000296,-, 13:32:34 4,CBLO/020709,T+0,30/06/2009,100.00,2.90,999841121.14,200906300000295,-, 13:32:34 5,CBLO/020709,T+0,30/06/2009,50.00,2.90,499920560.57,200906300000294,-, 13:32:34 6,CBLO/020709,T+0,30/06/2009,30.00,2.91,299952172.01,200906300000293,-, 13:32:34 SEL 1,CBLO/020709,T+0,30/06/2009,40.00,3.24,399928998.91,200906300000038,-, 09:47:22 2,CBLO/020709,T+0,30/06/2009,50.00,3.24,499911248.63,200906300000037,-, 09:47:22 3,CBLO/020709,T+0,30/06/2009,10.00,3.24,99982249.73,200906300000036,-, 09:47:22 4,CBLO/020709,T+0,30/06/2009,100.00,3.25,999821949.52,200906300000024,-, 09:31:09 5,CBLO/020709,T+0,30/06/2009,100.00,3.25,999821949.52,200906300000023,-, 09:31:09 6,CBLO/020709,T+0,30/06/2009,100.00,3.10,999830165.83,200906300000007,-, 09:11:55 7,CBLO/020709,T+0,30/06/2009,200.00,3.10,1999660331.67,200906300000006,-, 09:11:49 8,CBLO/020709,T+0,30/06/2009,200.00,3.05,1999665809.28,200906300000002,-, 09:11:28 390.00,800.00 3899368704.98,7998622703.09 Code:
1,CBLO/020709,T+0,30/06/2009,100.00,3.00,999835643.46,200906300000422,-, 15:04:42,BUY 2,CBLO/020709,T+0,30/06/2009,100.00,3.01,999835095.69,200906300000421,-, 15:04:42,BUY 3,CBLO/020709,T+0,30/06/2009,10.00,2.90,99984112.11,200906300000296,-, 13:32:34,BUY 4,CBLO/020709,T+0,30/06/2009,100.00,2.90,999841121.14,200906300000295,-, 13:32:34,BUY 5,CBLO/020709,T+0,30/06/2009,50.00,2.90,499920560.57,200906300000294,-, 13:32:34,BUY 6,CBLO/020709,T+0,30/06/2009,30.00,2.91,299952172.01,200906300000293,-, 13:32:34,BUY 1,CBLO/020709,T+0,30/06/2009,40.00,3.24,399928998.91,200906300000038,-, 09:47:22,SELL 2,CBLO/020709,T+0,30/06/2009,50.00,3.24,499911248.63,200906300000037,-, 09:47:22,SELL 3,CBLO/020709,T+0,30/06/2009,10.00,3.24,99982249.73,200906300000036,-, 09:47:22,SELL 4,CBLO/020709,T+0,30/06/2009,100.00,3.25,999821949.52,200906300000024,-, 09:31:09,SELL 5,CBLO/020709,T+0,30/06/2009,100.00,3.25,999821949.52,200906300000023,-, 09:31:09,SELL 6,CBLO/020709,T+0,30/06/2009,100.00,3.10,999830165.83,200906300000007,-, 09:11:55,SELL 7,CBLO/020709,T+0,30/06/2009,200.00,3.10,1999660331.67,200906300000006,-, 09:11:49,SELL 8,CBLO/020709,T+0,30/06/2009,200.00,3.05,1999665809.28,200906300000002,-, 09:11:28,SELL Last edited by vgersh99; 07-02-2009 at 02:07 PM.. Reason: code tags, PLEASE! |
|
||||
|
Try this....There should be some other better solution..
Code:
csplit -f out inputfile '/SEL/' grep 'CBLO' out00 >tmp1 sed 's/.*/&,BUY/' tmp1 >finalout grep 'CBLO' out01 >tmp2 sed 's/.*/&,SEL/' tmp2 >>finalout Last edited by Neo; 07-03-2009 at 10:23 AM.. Reason: code tags |
| Sponsored Links | ||
|
|
| Bits Awarded / Charged to lathavim for this Post | |||
| Date | User | Comment | Amount |
| 07-03-2009 | Neo | added code tags for user | -5,000 |