This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to simply extract certain filed from sam file

Hello everyone.

I have a sam file and only want to keep the read name and the FLAG field. How can I make it with awk?(And I do not want to keep the header)

Thanks for your answer!

sam assembly samtools

1 answer

How I'd do it:

samtools view mydata.bam | cut -f 1,2 > truncated.sam

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.
Upvote|Bookmark|Accept

sorry to bother again but I wonder if there is a way to speed up this process since my sam file is 140G and it is running really slowly...

Log in to answer this question.