![]() |
|
|
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 of file for Report Generation (String parsing and splitting) | umar.shaikh | Shell Programming and Scripting | 8 | 03-02-2009 01:38 AM |
| parsing fixed length field with yacc/bison | sungita | High Level Programming | 1 | 01-27-2009 11:27 AM |
| Read a string with leading spaces and find the length of the string | dayamatrix | UNIX for Dummies Questions & Answers | 2 | 11-13-2008 10:08 AM |
| Parsing a variable length record | Barb | UNIX for Dummies Questions & Answers | 17 | 10-01-2004 09:37 AM |
| Parsing data and retaining the full length of variable | app4dxh | Shell Programming and Scripting | 3 | 11-22-2002 12:04 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Parsing 286 length Character string
Hi Friends,
I have .txt file which has 13000 records. Each record is 278 character long. I am using below code to extract the string and it takes almost 10 minutes. Any suggestion please. cat filename.txt|while read line do f1=`echo $line|awk '{print substr($1,1,9)}'` f2=`echo $line|awk '{print substr($1,10,20)}'` f3=`echo $line|awk '{print substr($1,30,50)}'` f4=`echo $line|awk '{print substr($1,80,10)}'` f5=`echo $line|awk '{print substr($1,90,50)}'` f6=`echo $line|awk '{print substr($1,140,10)}'` f7=`echo $line|awk '{print substr($1,150,50)}'` f8=`echo $line|awk '{print substr($1,200,10)}'` f9=`echo $line|awk '{print substr($1,210,50)}'` f10=`echo $line|awk '{print substr($1,260,10)}'` f11=`echo $line|awk '{print substr($1,270,8)}'` f12=`echo $line|awk '{print substr($1,278,8)}'` s1=`echo $f1"|"$f2"|"$f3"|"$f4"|"$f5"|"` s2=`echo $f6"|"$f7"|"$f8"|"` s3=`echo $f9"|"$f10"|"` s4=`echo $f11"|"$f12` echo $s1$s2$s3$s4 >> FinalResult.txt done |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|