Reputation: 1
I'm trying to replace the word in shell script with sed -e command
but its not replacing , please help on that, i have tried the below
we have separate file in /data/docs/config.log
, in that file there is a word ?account for example ,
username acc, passsword acc, ?account.name
this ?account word needs to be replaced with word 'GLOBAL' using sed -e command ,
reacc = GLOBAL
sed -e "s/?account/$reacc/g" /data/docs/config.log > /data/docs/newconfig.log
but here the file newconfig.log has created with 0 size , no output written to the file , its not replacing its an empty file,
the output should be username acc, passsword acc, GLOBAL.name in newconfig.log
Upvotes: 0
Views: 412
Reputation: 11018
Being the only person who can reproduce the problem, you are pretty much on your own. There are plenty of things you can do to analyze the problem, though.
#!/bin/sh
. In cygwin for example, /bin/sh
is an alias for bash. Verify with: echo $SHELL
cat /data/docs/config.log > /data/docs/newconfig.log
work? Test again in a different folder.sed
really finished? Test without output redirection; see if the output is dumped to stdout.sed
itself. Who knows, maybe you have a weird alias that hides the real sed
. The most trivial filter is sed -e ''
, which should simply echo every line you type (just like cat
without parameters). Does that work? Then try some simple patterns.Systematically iterate between test cases that succeed and test case that fail, until you have found the breaking point. Doing so, you should be able to find the cause. Sorry, that's all I can do for you right now.
Upvotes: 1