使用Busybox sed在标签和CR之后提取数据

I have a script that extracts a file from a bash script combined with a binary file. It does so using the following GNU sed syntax sed -n '/__DATA__/{n;:1;n;p;b1}' /tmp/combined.file > /tmp/binary.file

However on executing this I get a sed: unterminated {

我在这里想念什么吗? BusyBox sed是否可以完成此任务?

评论
  • 小小乖
    小小乖 回复

    Assuming this question is related to your previous question, this will work using any awk in any shell on every UNIX box:

    $ awk '/^__DATA__$/{n=NR+1} n && NR>n' file
    3<ED>M-^PM-^PM-^PM-^PM-^
    

    When it finds __DATA__ it sets a variable n to the line number to start printing after and then when n is set prints every line for which the line number is greater than n.

    上面是针对您先前问题的输入文件运行的:

    $ cat -ev file
    echo "I: Installation finished!"$
    exit 0$
    $
    __DATA__$
    $
    3<ED>M-^PM-^PM-^PM-^PM-^$