在sed命令中使用转义序列

时间:2016-09-20 07:03:37

标签: sed

我想将;替换为TERMINATED BY '\034' STORED AS TEXTFILE;

我正在使用sed命令,但\0替换;

sed "s|;|TERMINATED BY '\034' STORED AS TEXTFILE|"

我试过了\\034,但它没有用。

2 个答案:

答案 0 :(得分:0)

使用此sed

sed "s|;|TERMINATED BY '\\\034' STORED AS TEXTFILE|"

答案 1 :(得分:0)

如果perl解决方案没问题,q operator在这种情况下很有帮助

$ echo 'abc ; xyz' | perl -pe "s/;/q(TERMINATED BY '\034' STORED AS TEXTFILE)/e"
abc TERMINATED BY '\034' STORED AS TEXTFILE xyz