![]() |
|
|
|
|
|||||||
| 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 |
| Splitting file based on number of rows | wahi80 | Shell Programming and Scripting | 2 | 06-03-2008 06:38 PM |
| Spliting file based on condition | Raamc | Shell Programming and Scripting | 2 | 05-15-2008 08:51 AM |
| Splitting av file in 2 at specific place based on textpattern | borgeh | Shell Programming and Scripting | 0 | 09-24-2007 04:02 PM |
| Read file based on condition | sbasetty | Shell Programming and Scripting | 5 | 01-31-2007 10:54 PM |
| splitting files based on text in the file | matrix1067 | Shell Programming and Scripting | 1 | 01-30-2006 04:45 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
I have a file given below. I want to split the file where ever I came across
***(instead you can put ### symbols in the file) . Also I need to name the file by extracting the report name from the first line which is in bold(eg:RPT507A) concatinated with DD(day on which the file runs). Can someone help me out in this...................... Thanks in advance srivsn ==================================================================================================== ================================ RPT507A BBW \CDL01 prd1 STORED VALUE SYSTEMS Page 1 Bath and Body Works Disputed Transactions Report Job: 65 Wed 01:55:12 Settlement file dated 10/25/2005 Oct 26 2005 ==================================================================================================== ================================ STORE CARD NUMBER DATE TIME AMOUNT MERCHANT INVOICE NO SEQ# CODE Reason __________ ___________________ __________ ________ __________________ ________ __________ ______ ____ ___________________ ==================================================================================================== ================================ RPT507A BBW \CDL01 prd1 STORED VALUE SYSTEMS Page 2 Bath and Body Works Disputed Transactions Report Job: 65 Wed 01:55:13 Settlement file dated 10/25/2005 Oct 26 2005 ==================================================================================================== ================================ STORE CARD NUMBER DATE TIME AMOUNT MERCHANT INVOICE NO SEQ# CODE Reason __________ ___________________ __________ ________ __________________ ________ __________ ______ ____ ___________________ ==================================================================================================== ================================ RPT507A BBW \CDL01 prd1 STORED VALUE SYSTEMS Page 3 Bath and Body Works Disputed Transactions Report Job: 65 Wed 01:55:13 Settlement file dated 10/25/2005 Oct 26 2005 ==================================================================================================== ================================ STORE CARD NUMBER DATE TIME AMOUNT MERCHANT INVOICE NO SEQ# CODE Reason __________ ___________________ __________ ________ __________________ ________ __________ ______ ____ ___________________ ==================================================================================================== ================================ RPT507A BBW \CDL01 prd1 STORED VALUE SYSTEMS Page 4 Bath and Body Works Disputed Transactions Report Job: 65 Wed 01:55:14 Settlement file dated 10/25/2005 Oct 26 2005 ==================================================================================================== ================================ STORE CARD NUMBER DATE TIME AMOUNT MERCHANT INVOICE NO SEQ# CODE Reason __________ ___________________ __________ ________ __________________ ________ __________ ______ ____ ___________________ ==================================================================================================== ================================ RPT507A BBW \CDL01 prd1 STORED VALUE SYSTEMS Page 5 Bath and Body Works Disputed Transactions Report Job: 65 Wed 01:55:15 Settlement file dated 10/25/2005 Oct 26 2005 ==================================================================================================== ================================ STORE CARD NUMBER DATE TIME AMOUNT MERCHANT INVOICE NO SEQ# CODE Reason __________ ___________________ __________ ________ __________________ ________ __________ ______ ____ ___________________ ==================================================================================================== ================================ RPT507A BBW \CDL01 prd1 STORED VALUE SYSTEMS Page 6 Bath and Body Works Disputed Transactions Report Job: 65 Wed 01:55:16 Settlement file dated 10/25/2005 Oct 26 2005 ==================================================================================================== ================================ STORE CARD NUMBER DATE TIME AMOUNT MERCHANT INVOICE NO SEQ# CODE Reason __________ ___________________ __________ ________ __________________ ________ __________ ______ ____ ___________________ ==================================================================================================== ================================ RPT507A BBW \CDL01 prd1 STORED VALUE SYSTEMS Page 7 Bath and Body Works Disputed Transactions Report Job: 65 Wed 01:55:16 Settlement file dated 10/25/2005 Oct 26 2005 ==================================================================================================== ================================ STORE CARD NUMBER DATE TIME AMOUNT MERCHANT INVOICE NO SEQ# CODE Reason __________ ___________________ __________ ________ __________________ ________ __________ ______ ____ ___________________ * * * END OF REPORT * * * ### Job 65 (RPT507A BBW ): 390 lines, 7 pages, 10/26/2005 01:55:16 ==================================================================================================== ================================ RPT507B BBW \CDL01 prd1 STORED VALUE SYSTEMS Page 1 Bath and Body Works Disputed Transactions Report Job: 86 Wed 01:55:17 Settlement file dated 10/25/2005 Oct 26 2005 ==================================================================================================== ================================ * * * END OF REPORT * * * ### Job 86 (RPT507B BBW ): 25 lines, 1 pages, 10/26/2005 01:55:17 ==================================================================================================== ================================ RPT507B BBWCC \CDL01 prd1 STORED VALUE SYSTEMS Page 1 White Barn Candle Company Disputed Transactions Report Job: 87 Wed 01:55:17 Settlement file dated 10/25/2005 Oct 26 2005 ==================================================================================================== ================================ * * * END OF REPORT * * * |
| Forum Sponsor | ||
|
|
|
|||
|
I'd use perl for something that involved.Something like:-
#!/usr/bin/perl # Use Perls localtime function if you want, but this is plainer $date=`date '+%d_%m'`; chomp($date); open (INPUTFILE, "<./report_file.rep"); (@file)=<INPUTFILE>; close INPUTFILE; @report_names=grep (/RPT/,@file); @reports=split(/\*\*\*.*?\*\*\*/, join("",@file)); $count=0; foreach $report_name(@report_names) { $report_name=~s/(\w+)\W.*/\1/; chomp($report_name); $filename="${report_name}_${date}"; open (FILE, ">./$filename"); print FILE "$reports[$count]\n"; close FILE; $count++; } You'll probably need to tweak the 'split' function a bit so each file contains exactly what you want, but that (roughly) should do it. |
|||
| Google The UNIX and Linux Forums |