并行化 sed 给出不同的输出

Has*_*ard 2 shell sed quoting gnu-parallel

然而,尝试并行化 sed 操作,当并行版本工作时,它会返回错误的输出。

我想并行化的 sed 操作(有效)

sed 's/\s.*$// ; s/\(.*\)/\L\1/' < oldfile.txt > newfile.txt
Run Code Online (Sandbox Code Playgroud)

我的上述 sed 操作的并行版本(由于某种原因无法正常工作):

parallel -a oldfile.txt -k --block $BYTES --pipe-part "sed 's/\s.*$// ; s/\(.*\)/\L\1/'" > newfile.txt
Run Code Online (Sandbox Code Playgroud)

Ole*_*nge 5

这通常是由于双引号引起的。

引用很烦人,所以请尝试使用 shell 函数:

mysed() {
    sed 's/\s.*$// ; s/\(.*\)/\L\1/'
}
export -f mysed

parallel -a oldfile.txt -k --block -1 --pipe-part mysed > newfile.txt
Run Code Online (Sandbox Code Playgroud)