Re: sed and bash-script --- help in search and replace content of file.



On Jul 24, 8:13 pm, Dave B <da...@xxxxxxxxxxxx> wrote:
Ra...@xxxxxxxxxxxx wrote:
value=0;
while read line
do
value=`expr $value + 1`;
value1='@'$value'@';
echo  $line  is replace by $value1  >> file_fin
sed   's/$line/$value1/g'  data_file;
done < "file_map"
---------------------------------------

In above content of file_fin comes perfectly fine, but in data file
text is not replaced !

First, you put variables between single quotes when invoking sed, so the
variables are not interpolated by the shell and thus sed does not see their
values. Use double quotes instead.
Second, the sed command writes to standard output, thus even if you
corrected the first problem the file data_file would still remain unchanged.

There are other problems, but the two above are likely the explanation of
what you're seeing.
Thanks, i did that... now it is only replacing First Value... i am
redirecting to output file.

bash$cat ./script.sh
value=0;
while read line
do
value=`expr $value + 1`;
value1='@'$value'@';
echo $line is replace by $value1 >> file_fin
sed "s/$line/$value1/g" data_file >> output;
done < "file_map"


Tnx.

--
echo 0|sed 's909=oO#3u)o19;s0#0ooo)].O0;s()(0bu}=(;s#}#.1m"?0^2{#;
s)")9v2@3%"9$);so%op]t(p$e#!o;sz(z^+.z;su+ur!z"au;sxzxd?_{h)cx;:b;
s/\(\(.\).\)\(\(..\)*\)\(\(.\).\)\(\(..\)*#.*\6.*\2.*\)/\5\3\1\7/;
tb'|awk '{while((i+=2)<=length($1)-18)a=a substr($1,i,1);print a}'

.



Relevant Pages

  • TZ all working and well worth the work
    ... replacing lm330 that the tech tore the leads going to the sockets. ... isolated the first problem of replacing the chips he caused another problem ... I am working on a AFM. ... thinking that the AFM will cap out the collection. ...
    (rec.games.pinball)
  • Re: Ghostscript converting pdf problem
    ... creating the output file, data is sent to the printer. ... I'm also not sure how whatever-os-this-is interprets single quotes. ... ghostscript prints to the screen). ...
    (comp.lang.postscript)
  • Re: sed and bash-script --- help in search and replace content of file.
    ... echo $line is replace by $value1>> file_fin ... In above content of file_fin comes perfectly fine, but in data file ... First, you put variables between single quotes when invoking sed, so the ... corrected the first problem the file data_file would still remain unchanged. ...
    (comp.unix.shell)
  • Re: Handling apostrophes and other characters
    ... then you now have to find someway to escape real underscores. ... > the data you display, then what if the original input string looked like ... > So if you tried to replace the underscores with single quotes for display, ... Note that replacing a single ...
    (microsoft.public.inetserver.asp.general)
  • Re: What Did I Miss Here?
    ... If I don't use the replace function the sql statement ... >> text fields from a form to string fields in a table. ... >> some single quotes so in my update command I am replacing single quotes ...
    (microsoft.public.dotnet.framework.adonet)