bash zcat head causes pipefail?

后端 未结 2 1493
鱼传尺愫
鱼传尺愫 2020-12-01 14:33
set -eu 
VAR=$(zcat file.gz  |  head -n 12)

works fine

set -eu   -o pipefail
VAR=$(zcat file.gz  |  head -n 12)

c

2条回答
  •  佛祖请我去吃肉
    2020-12-01 15:11

    Alternatively, you can use

    zcat file.gz  | awk '(NR<=12)'
    

    The price is that you need to go through all the zcat, no early stop based on the lines you specified.

提交回复
热议问题