Paul
unread,Mar 14, 2011, 12:26:35 PM3/14/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Linux Users Group
Hello,
I am struggling to find a solution to the following apparently simple
problem, so any help would be much appreciated.
Here is a simple example of what I'm trying to do.
From the console of a linux machine running Fedora-12, if I do
echo "AB" > file
FILE=file
sed "s/AB/12/" $FILE
I get, as expected,
12
I can also do
COMMAND="sed s/AB/12/ $FILE"
$COMMAND
and again I get
12
So far so good. If, however, I now introduce a space with
echo "A B" > file
I'd like to find the setting for COMMAND which is equivalent to
sed "s/A B/1 2/" $FILE
1 2
I've tried a number of obvious variations, but I can't get any to
work, for example,
COMMAND="sed s/A B/1 2/ $FILE"
$COMMAND
sed: -e expression #1, char 3: unterminated `s' command
COMMAND="sed \"s/A B/1 2/\" $FILE"
$COMMAND
sed: -e expression #1, char 1: unknown command: `"'
COMMAND='sed "s/A B/1 2/" $FILE'
$COMMAND
sed: -e expression #1, char 1: unknown command: `"'
COMMAND="sed 's/A B/1 2/' $FILE"
$COMMAND
sed: -e expression #1, char 1: unknown command: `''
Thanks,
Paul