On Fri, 2007-03-09 at 15:01 -0800, L.V.Gandhi wrote: > I have made a script like this as test1 > #!/bin/bash > line="3IINFOTECH,20050422000000,118,118,96,98.1,8260440" > olds=$(echo "$line"|cut -d, -f2) > echo $olds > da=${olds:0:8} > echo $da > echo "$line" > temp1 > sed -e 's/$olds/$da/' temp1 >>temp > cat temp1 > cat temp > When I run get as > [EMAIL PROTECTED]:~/.qtstalker/data0/export$ test1 > 20050422000000 > 20050422 > 3IINFOTECH,20050422000000,118,118,96, 98.1,8260440 > 3IINFOTECH,20050422000000,118,118,96,98.1,8260440 > I don't find any replacement. Where am I wrong? what should be done to > get the replacement done?
The problem is that you've used single quotes, preventing shell expansion of your variables. Try: sed -e "s/$olds/$da/" temp1 >>temp My guess is that will work for you. -davidc -- gpg-key: http://www.zettazebra.com/files/key.gpg
signature.asc
Description: This is a digitally signed message part