JackJack
JackJack

Reputation: 7

Get tsv file with header using sed

So I wrote this sed commands to get .tsv files filtered (in this case) by chromosome 19. Unfortunatley i dont know how to get the Header for the tsv file as well. So far i only get headerless data. how should I modify my code?

wget https://www.dropbox.com/s/dataset.tsv.bgz -O temp.data.99.tsv.bgz
gunzip -c temp.data.99.tsv.bgz > temp.data.99.tsv 
sed -n '/^19:/p' temp.data.99.tsv | sed 's/:/   /g' > finished_tsv_files/temp.data.99_Chr_19.tsv
rm temp.data.99.tsv

Upvotes: 0

Views: 191

Answers (1)

Cyrus
Cyrus

Reputation: 88646

Replace

/^19:/p

with

1p; /^19:/p

to output first line, too.

Upvotes: 1

Related Questions