Take nth column in a text file

前端 未结 6 1061
小蘑菇
小蘑菇 2020-11-29 20:22

I have a text file:

1 Q0 1657 1 19.6117 Exp
1 Q0 1410 2 18.8302 Exp
2 Q0 3078 1 18.6695 Exp
2 Q0 2434 2 14.0508 Exp
2 Q0 3129 3 13.5495 Exp

6条回答
  •  庸人自扰
    2020-11-29 20:34

    If you are using structured data, this has the added benefit of not invoking an extra shell process to run tr and/or cut or something. ...

    (Of course, you will want to guard against bad inputs with conditionals and sane alternatives.)

    ...
    while read line ; 
    do 
        lineCols=( $line ) ;
        echo "${lineCols[0]}"
        echo "${lineCols[1]}"
    done < $myFQFileToRead ; 
    ...
    

提交回复
热议问题