The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Directory sizes loop optimization la_womn Shell Programming and Scripting 6 05-16-2008 11:05 PM
On Premature Optimization iBot Complex Event Processing RSS News 0 02-12-2008 05:20 AM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 03:06 AM
Program crashes with optimization level O2 Yuriy07 HP-UX 3 08-17-2007 01:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-20-2007
aju_kup aju_kup is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 189
Help on optimization of the script

Hi,

I have prepared script which is taking more time to process. find below script and help me with fast optimized script:-



cat name.txt | while read line
do

name=$(echo $line| awk '{print $8}')

MatchRecord=$(grep $name abc.txt | grep -v grep )

echo "$line | $MatchRecord" | awk -F"|" '
BEGIN { format = "%-6s %-10s %-10s %-4s %-19s %-6s %-2s %-6s %-4s\n" }
{
split($1, rsp," ")
split($2, req," ")
printf format, req[1], rsp[2], rsp[3], rsp[4], req[5], rsp[6], rsp[7],
rsp[8], rsp[9]
}'
done >> /tmp/new.txt
  #2 (permalink)  
Old 11-20-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
If you show us a sample input of those files and what you are trying to achieve, then it will be easy to relate the script.

As such here are some tips.

Change

Code:
cat name.txt | while read line
do
...
...
done >> /tmp/new.txt
to
Code:
while read line
do
...
...
done < name.txt >> /tmp/new.txt
Change

Code:
MatchRecord=$(grep $name abc.txt | grep -v grep )
to
Code:
MatchRecord=$(grep $name [a]bc.txt)
From what I see, probably the whole script can be written in awk or perl.
  #3 (permalink)  
Old 11-20-2007
aju_kup aju_kup is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 189
Thanks for quick reply


name.txt

...... 12345 67890 0000 ................... ...... 00 12345 2131

abc.txt

111111 12345 67890 0000 1234567890 12345 dfadsf

in both file 8th field is common. using common field i want to fill the blank fileds in name.txt for this value will be taken from abc.txt
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0