![]() |
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 |
| SCO unix server performance tuning | forumuser7 | SCO | 0 | 03-22-2006 11:04 AM |
| Oracle-performance tuning | kthri | Shell Programming and Scripting | 9 | 12-07-2005 12:31 PM |
| Performance Tuning | domyalex | UNIX for Dummies Questions & Answers | 1 | 07-15-2005 10:55 AM |
| EXT3 Performance tuning | malcom | Filesystems, Disks and Memory | 3 | 06-14-2005 11:27 PM |
| Performance tuning. | TRUEST | UNIX for Dummies Questions & Answers | 1 | 03-21-2003 02:50 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Performance Tuning
Hi All,
In last one week, i have posted many questions in this portal. At last i am succeeded to make my 1st unix script. following are 2 points where my script is taking tooooo long. 1. Print the total number of records excluding header & footer. I have found that awk 'END{print NR - 2}' <filename> will give exact result. But my file has 520 columns seperated with ^~^. while using this command, error is 'too long...... record'. so i have used like this. a=` cut -d~ -f1 NAM2008101601.OUT |awk 'END{print NR - 2}' ` But this is taking too long. 2. i need sum of amount column. So first i have cut that column & paste it in a file. Then i have calculated sum. But it is also taking long time. cut -d~ -f27 $FILE_NAME | cut -c2-23 > amount tot_val=`awk '{a+=$0}END{printf "%.5f\n",a}' amount` Appriciate if someone can help me to get alternatives which speed up this process. Thnaks Amit |
|
||||
|
For the point 1, since you are assuming that there will be always header and footer, not sure why you need to read whole file NAM2008101601.OUT to get record count.
Can you try using file size and record length to get record count, subtract 2 to get data records count? 1) Take file size from ls -l NAM2008101601.OUT 2) Get the record length, if it is not constant, then use wc to get record length 3) Total records = file size/record length 4) Subtract 2 from step 3, to take header/trailer counts. Hope this might work. |
![]() |
| Bookmarks |
| Tags |
| performance |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|