Solaris sed标签太长了

时间:2013-12-30 13:35:40

标签: sed

我正在尝试执行一个shell文件,其中有一行:

sed -ne ':1;/PinnInstitutionPath/{n;p;b1}' Institution | sed -e s/\ //g | sed -e s/\=//g | sed -e s/\;//g | sed -e s/\"//g | sed -e s/\Name//g

结果显示错误消息:"Label too long: :1;/PinnInstitutionPath/{n;p;b1}"

我是linux上的菜鸟,所以任何人都可以帮我解决这个问题,谢谢!

2 个答案:

答案 0 :(得分:3)

尝试更改

sed -ne ':1;/PinnInstitutionPath/{n;p;b1}'

sed -ne ':1' -e '/PinnInstitutionPath/{n;p;b1}'

此外,您无需多次致电sed

sed -ne 's/[ =;"]//g; s/Name//g' -e ':1' -e '/PinnInstitutionPath/{n;p;b1}'

答案 1 :(得分:2)

关于Solaris(SunOS)中的“sed:标签太长” - 如果使用标签,则需要将命令拆分为多行。 在你的情况下

sed -ne ':1
    /PinnInstitutionPath/{
    n
    p
    b 1
    }' Institution | sed -e s/\ //g -e s/\=//g -e s/\;//g -e s/\"//g -e s/\Name//g

相关问题