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 > Shell Programming and Scripting
.
google unix.com



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
Find and replace kiran_418 UNIX for Dummies Questions & Answers 2 05-06-2008 06:32 PM
Find and Replace NycUnxer UNIX for Dummies Questions & Answers 4 03-06-2008 12:20 AM
fast search and replace in all files dbsurf Shell Programming and Scripting 21 02-01-2008 03:42 AM
find and replace mahabunta UNIX for Dummies Questions & Answers 7 09-21-2006 01:05 PM
find and replace vikas_j@hotmail UNIX for Dummies Questions & Answers 3 02-25-2002 05:41 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-06-2008
jkl_jkl jkl_jkl is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 46
Fast way of find and replace, help

Hi All,

I have nearly 200 files in a directory, each file is of nearly of 5000 lines.
Each line of each file is having its 3rd field to be replaced by corresponding replace_string(2nd field of file1.out below).

i.e.
-Search the 3rd field of each line of each of 200 files in file1.out, get the replace_string(2nd field of file1,out),
-replace that in each line(and in turn each file)

Code:
file1.out (is more than 5000 lines)
++++++++++++++++++++++++++++++++++++

1204675041      1204675051
1204675042      1204675063
1204675111      1204675142
1204675112      1204675154
1204675113      1204675166
1204675114      1204675177
1204675115      1204675189
1204675116      1204675200
<nearly 5000 more lines>
Code:
$ ls | while read FILE
> do
> awk -F "|" '{print $3}' $FILE | while read TIME
> do
> TORP=`awk '$1=="'"$TIME"'" {print $2}' file1.out`
> awk 'BEGIN{OFS=FS="|"} $3=="'"$TIME"'" {$3="'"$TORP"'"}{print}' $FILE > $FILE.tmp
> done
> done
I tried using bash with AWK to do the same(like above), the performance is not that good(its just hanging).

Could anyone suggest me a fast search and replace technique considering my scenario.

HTH,
jkl_jkl
 

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 04:14 AM.


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