Reputation: 3390
I've tried several different formats, but none of them are working. Any assistance would be appreciated:
[root@home:/home/users/jlefler]$ sed "s/[',#,`,@]//g" stage_data.out > stage_data
> ^C
[root@home:/home/users/jlefler]$ sed "s/[\',#,`,@]//g" stage_data.out > stage_data
> ^C
[root@home:/home/users/jlefler]$ sed "s/[#,`,@,\\']//g" stage_data.out > stage_data
> ^C
Upvotes: 1
Views: 1084
Reputation: 123690
Let's ask shellcheck:
sed "s/[',#,`,@]//g" stage_data.out > stage_data
^-- SC1073: Couldn't parse this backtick expansion.
The backtick is the problem, not the single quote. Just escape it:
sed "s/[',#,\`,@]//g" stage_data.out > stage_data
Here's an example of this in action:
$ echo "'#@foo" > stage_data.out
$ sed "s/[',#,\`,@]//g" stage_data.out > stage_data
$ cat stage_data
foo
Upvotes: 2
Reputation: 16156
Your problem is caused by sh
, not by sed
.
Double quotes still allow certain special characters to have special meanings, such as $
and, in this case `
.
This works:
echo "a'b'c" | sed -e "s/['#\`@]//g"
Or you could avoid all shell-related problems by sticking your patterns in a file and using sed -f
Upvotes: 3