![]() |
|
|
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 |
| Search, replace string in file1 with string from (lookup table) file2? | gstuart | Shell Programming and Scripting | 9 | 06-08-2009 07:11 AM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |
| String Search & Replace | IwishIknewC | UNIX for Dummies Questions & Answers | 1 | 03-25-2006 06:28 AM |
| Search and replace string between 2 points | whited05 | Shell Programming and Scripting | 3 | 10-11-2005 03:05 PM |
| string search replace | krishna | UNIX for Advanced & Expert Users | 1 | 12-19-2001 01:49 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Need to replace all occurences of a search string using sed
All,
Here is what I am searching for using sed. 1 00640000106798 I want to replace that with the following. 8 0064B0000106798 I can do this easy enough from the command line using sed but I need to put the search string in a file and then execute the sed command within a shell script. I think the problem has something to do with how the spaces are being evaluated when reading from the file as the search string is never being found. Here is what I have so far. Please Help!! cat $1 | while read LINE do echo $LINE > LINE.out firstVar=$(awk -F" " '{print $1}' LINE.out) secondVar=$(awk -F" " '{print $2}' LINE.out) space=" " testVar=${firstVar}$space${secondVar} #This makes the string 1 00640000106798 When I execute the following line the search string is never found. sed 's/"$testVar"/8 0064B0000106798/g' WhatIf_4_Forecast.dat > tester.dat |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|