I have a file with many rows as below. I just want to extract columns 2,3,5,6; but the third column without the 'chr' prefix:


585     ENST00000417324 chr1    -       34553   36081   36081   36081   3  


ENST00000417324 1 34553 36081

I would use awk as the task is very simple, but I don't know how to get rid of the 'chr' prefix.

Thank you!


You could substitute chr at the beginning of the third field with an empty string:

awk '{ sub(/^chr/,"",$3); print $2,$3,$5,$6 }' file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.