如何用 sh 遍历 awk 的每个输出?
How to iterate over each output of awk with sh?
我有一个 test.sh
文件,它通过文本文件 test.bed
:
1 31 431
1 14 1234
1 54 134
2 435 314
2 314 414
和
while read line;do
echo $line
# ... more code ... #
done < <(awk -F '\t' ' == 1 {print [=11=]}' test.bed )
运行 这与 bash test.sh
一起工作,但与 sh test.sh
它给出语法错误。我如何使用 sh
而不是 bash
来执行上述操作?
它给出的错误是
test.sh: line 5: syntax error near unexpected token `<'
test.sh: line 5: `done < <(awk -F '\t' ' == 1 {print [=12=]}' test.bed )'
Process Substitution 是 bash
扩展 - POSIX
未指定。这是 sh
兼容的..
#!/bin/sh
awk -F '\t' ' == 1 {print [=10=]}' test.bed | while read line; do
echo $line
# ... more code ... #
done
我有一个 test.sh
文件,它通过文本文件 test.bed
:
1 31 431
1 14 1234
1 54 134
2 435 314
2 314 414
和
while read line;do
echo $line
# ... more code ... #
done < <(awk -F '\t' ' == 1 {print [=11=]}' test.bed )
运行 这与 bash test.sh
一起工作,但与 sh test.sh
它给出语法错误。我如何使用 sh
而不是 bash
来执行上述操作?
它给出的错误是
test.sh: line 5: syntax error near unexpected token `<'
test.sh: line 5: `done < <(awk -F '\t' ' == 1 {print [=12=]}' test.bed )'
Process Substitution 是 bash
扩展 - POSIX
未指定。这是 sh
兼容的..
#!/bin/sh
awk -F '\t' ' == 1 {print [=10=]}' test.bed | while read line; do
echo $line
# ... more code ... #
done