![]() |
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 |
| parsing a string in a shell script | asutoshch | Shell Programming and Scripting | 19 | 05-26-2008 09:18 PM |
| shell script parsing with sed | jjamd64 | UNIX for Dummies Questions & Answers | 5 | 12-11-2007 04:51 PM |
| Parsing text from one line with shell scripts | th3g0bl1n | UNIX for Dummies Questions & Answers | 3 | 10-19-2007 05:49 AM |
| Help in parsing a CSV file with Shell script | mihirk | Shell Programming and Scripting | 10 | 06-24-2007 10:58 AM |
| shell script argument parsing | rmjoe | Shell Programming and Scripting | 1 | 07-28-2005 03:37 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Parsing a line in Shell Script
I have record line somthing like below with first line showing char spacing not real record line
1 | 2 | 3rd Field--------------|-4th field--| This is charcatersapcing of line DF20000000000000000130.7890000000750 I shoudl get two line from above line 1st line should 1 | 2 | 3rd Field-------------|4th field--| This is charcatersapcing of line DF125000000000000000000000000000000 Here the second field is (2nd - 4th filed in the above line 2ndst line should 1 | 2 | 3rd Field---------------|-4thfield--| This is charcatersapcing of line DF075000000000000000130.7890000000000 respective (ie 1 2 3 4) Field lenths in all the records are same Please let me know what is best way of doing this. Thanks uni Last edited by unishiva; 10-31-2007 at 07:35 PM.. |
|
||||
|
Sorry for the confusion
Let me put it simple ..I wanted crate two lines by parsing one lin by exracting certian fields
I have record line somthing like below (Origanal line before Parsing) DF02000XXYYYY00200.89ZZPPPP00800 Field discription : DF - FirstField (Character Position 1 to 2) 02000 - Second Field (Characters position 3 to 7) XX third Field (Characters position 8 to 9) YYYY Fourth Field (Characters position 10 to 13) 00200.89 fifth Field (Characters position 14 to 21) ZZ sixth Field (Characters position 22 to 23) PPPP seventh Field (Characters position 24 to 27) 00800 eightth Field (Characters position 28 to 32) I wanted to create two new line by parsing above line (each line having again 7 fields) 1st line should loolk line DF0120000000000000000000000000000 DF - First Field (Same as that of origanal iine) 01200 - Second Field ( This is Difference between 2ndfiled and 8th Field of origanla line) All other fields are 0's 2nd Line should look like DF00800XXYYYY00200.89ZZ000000000 DF - First Field (Same as that of origanal iine) 00800 - Second Field ( This is same as that of the 8th Field of Origanal line) XX - thrid field same as that of origanal line YYYY - fourth field Same as that of the origanal line 00200.89 - Fifth field same as that of orignal line All other fields should be zeros I hope this time it is clear. If you still some clarification .. I will write back. Thanks for all your help. Thanks Uni |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|