4

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:

Input:

585     ENST00000417324 chr1    -       34553   36081   36081   36081   3  

Output:

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!

7

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
0

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.