Hi Mehmet,
A sample input file would help a little. My first guess is there are no
quotes around the $field:
grep -w "$field"
Also it's not the most elegant script - which you may not care about :)
Nima
On Sat, Mar 6, 2010 at 8:45 PM, Mehmet Yousouf <
[email protected]> wrote:
> Hi,
> I'm having trouble with the following search and replace script:
>
> #!/bin/bash
> # two parameters are passed in, a mapping file and the text file to replace
> in
>
> for fields in $(cat ./Mapping/$1-Mapping |awk 'BEGIN{FS=","}{print $2}')
> do
> searchstring= $fields
> replacestring="`grep -w $fields ./Mapping/$1-Mapping |awk
> 'BEGIN{FS=","}{print $1}'`"
> sed -e "s/$searchstring, / $replacestring, /g" $2 >TestResult
> done
>
> it fails if there is a $ sign in the variable $field e.g. amount_$ . How
> can I get grep to "behave" the way I want?
> Any help would be appreciated.
>
> Regards, Mehmet
>
>
>
> --
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
>
--
http://me.nima.id.au/
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html