问题:

我运行几个替换命令作为mavencolorize脚本的核心。 其中一个sed命令使用一个正则表达式,它可以在shell中找到,如下所述 可以在此处找到当前(不工作)的实现。

当我将该命令的一个变体包含到脚本中时,会出现不同的行为:

变式1:

$ sed -re "s/([a-zA-Z0-9./\\ :-]+)/\1/g"

适应脚本:

-re "s/WARNING: ([a-zA-Z0-9./\\ :-]+)/${warn}WARNING: \1${c_end}/g" \

错误: shell输出的信息与我输入$ sed信息相同。 奇怪!?


变式2:

$ sed -e "s/\([a-zA-Z0-9./\\ :-]\+\)/\1/g"

适应脚本:

-e "s/WARNING: \([a-zA-Z0-9./\\ :-]\+\)/${warn}WARNING: \1${c_end}/g" \

错误:

sed:-e表达式#7,char 59:`s’命令的RHS上的引用\\ 1无效

I run several substitution commands as the core of a colorize script for maven .One of the sed commands uses a regular expression which works find in the shell as discussed here .The current (not working) implementation can be found here .When I include one of the variants of the command into the script different behavior occurs:Variant 1:Adapted to the script:Error: The shell outputs the same information as if I would type $ sed .Strange!?Variant 2:Adapted to the script:Error:sed: -e expression #7, char 59: invalid reference \\1 on `s’ command’s RHS

问题:

我正在尝试替换Mac OS X上Makefile中的字符串以交叉编译到iOS。 该字符串具有嵌入的双引号。 该命令是:

sed -i "" 's|"iphoneos-cross","llvm-gcc:-O3|"iphoneos-cross","clang:-Os|g' Configure

错误是:

sed: RE error: illegal byte sequence

我尝试用双引号,逗号,破折号和冒号转义,但没有任何乐趣。 例如:

sed -i "" 's|\"iphoneos-cross\"\,\"llvm-gcc\:\-O3|\"iphoneos-cross\"\,\"clang\:\-Os|g' Configure

我花了点时间调试问题。 有谁知道如何让sed打印非法字节序列的位置? 还是有人知道非法字节序列是什么?

I’m trying to replace a string in a Makefile on Mac OS X for cross-compiling to iOS.The string has embedded double quotes.The command is:And the error is:I’ve tried escaping the double quotes, commas, dashes, and colons with no joy.For example:I’m having a heck of a time debugging the issue.Does anyone know how to get sed to print the position of the illegal byte sequence?Or does anyone know what the illegal byte sequence is?