在 OracleLinux8.9 上使用 sed 出现 Unix 错误“Invalid RangeEnd” - 代码适用于 OL 7.9

问题描述 投票:0回答:1

我在使用 sed 处理文件时遇到错误。 我们让这个核心在 OracleLinux 7.9 上成功运行,但在 OracleLinux 8.9 上,相同的代码因无效范围结束而失败

sed -r -f ./sed/transform-diff.sed  < 15-diffToUpdate.xml > 15-diffToUpdate.xml.tmp
sed: file ./sed/transform-diff.sed line 11: Invalid range end

其中transform-diff-sed是:

# sed script to transform generated Liquibase diff file

# Problem to solve: If a column is dropped, a RDBM drops as well every index, that uses these columns. In the
# Liquibase diff script, columns are dropped first, indexes later. In the previously described case, an index
# might already be deleted and the update might fail.
# Solution: Put every <dropIndex> in a separate <changeSet>, containing a <indexExists> preCondition that
# only executes the <dropIndex> if it still exists.
/<changeSet/ {
    N
    s%([ \t]*)<changeSet author="([a-zA-Z \(\)]*)" id="([a-zA-Z0-9-]*)">[ \t\n]*(<dropIndex indexName="([a-zA-Z0-9_]*)"[a-zA-Z_-=" ]*>)%\1<changeSet author="\2" id="\3a">\n\1\1<preConditions onFail="CONTINUE">\n\1\1\1<indexExists indexName="\5" />\n\1\1</preConditions>\n\1\1\4\n\1</changeSet>\n\1<changeSet author="\2" id="\3b">%g
}

# Problem to solve: Liquibase diff reads from type FLOAT not the precision but the the required bytes adds
# this information to its change log. A FLOAT (with default precision of 126) is transformed to a FLOAT(22),
# which is too short. By removing all precision information in the generated diff file, we avoid this
# problem.
/type="FLOAT\(/ {
    s%type="FLOAT\([0-9]*\)"%type="FLOAT"%g
}

有如何继续的提示吗? sed 命令是多年前开发的,可以更改。我确实需要让它运行

我隔离了代码并让它在两台单独的机器上运行

1.) Oracle Linux 7.9 --> 工作正常,输出文件已填满

2.) Oracle Linux 8.9 --> 错误消息,输出文件为空

蒂亚 乌韦

sed
1个回答
0
投票

-
中的
[a-zA-Z_-=" ]
移至末尾:
[a-zA-Z_=" -]

© www.soinside.com 2019 - 2024. All rights reserved.