How do I replace a string with a newline using a bash script and sed?

后端 未结 7 2026
夕颜
夕颜 2021-02-13 09:41

I have the following input:

Value1|Value2|Value3|Value4@@ Value5|Value6|Value7|Value8@@ Value9|etc...

In my bash script I would like to replace

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-13 10:31

    How about:

    for line in `echo $longline | sed 's/@@/\n/g'` ; do
        $operation1 $line
        $operation2 $line
        ...
        $operationN $line
        for field in `echo $each | sed 's/|/\n/g'` ; do
            $operationF1 $field
            $operationF2 $field
            ...
            $operationFN $field
        done
    done
    

提交回复
热议问题