![]() |
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 |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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
Could anyone suggest me a fast search and replace technique considering my scenario. HTH, jkl_jkl |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|