Re: sed and bash-script --- help in search and replace content of file.
- From: "Raxit@xxxxxxxxxxxx" <raxitsheth2000@xxxxxxxxx>
- Date: Thu, 24 Jul 2008 08:31:23 -0700 (PDT)
On Jul 24, 8:13 pm, Dave B <da...@xxxxxxxxxxxx> wrote:
Ra...@xxxxxxxxxxxx wrote:Thanks, i did that... now it is only replacing First Value... i am
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.
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}'
.
- Follow-Ups:
- References:
- Prev by Date: Re: sed and bash-script --- help in search and replace content of file.
- Next by Date: Re: sed and bash-script --- help in search and replace content of file.
- Previous by thread: Re: sed and bash-script --- help in search and replace content of file.
- Next by thread: Re: sed and bash-script --- help in search and replace content of file.
- Index(es):
Relevant Pages
|