Reputation:
I am having a little problem with putting a regex inside a sed command, this is my code:
RAW_LIST_B=`echo $RAW_LIST_A | sed s/[0-9a-f]{8} / /g`
And i get this error :
sed: -e expression #1, char 13: unterminated `s' command
I am not sure how to quote the [0-9a-f]{8}
so that it removes all 8 digit hex numbers and trailing space from RAW_LIST_A
Thanks,
Upvotes: 0
Views: 174
Reputation: 17120
Do this:
RAW_LIST_B=`echo $RAW_LIST_A | sed 's/[0-9a-f]\{8\} / /g'`
Since you did not quote the argument to sed
, the shell splitted it into three arguments: s/[0-9a-f]{8}
, /
and /g
before passing it to sed
.
Also, note the backslashes to escape the curly brackets.
Upvotes: 2
Reputation: 6339
You should enclose sed experssion into a quotes so it will be one string parameter passed to sed by shell
RAW_LIST_B=`echo $RAW_LIST_A | sed "s/[0-9a-f]\{8\} //g"`
Sample output:
$ echo "hello a5a5a5a6 world" | sed "s/[0-9a-f]\{8\} //g"
hello world
Upvotes: 1