Sample Header Ad - 728x90

Retrieve the 1st and 5th column of a tab-separated file, convert the spaces in the 5th to tabs

1 vote
4 answers
548 views
I have a tsv file with tab-separated columns. I want to obtain the 5th column, which has space-separated values. Convert the space-separation to tab-separation and save as a new file. Attempt: cut -d"\t" -f"4" input.tsv awk -v OFS="\t" '$1=$1' input.tsv > output.tsv Input: Composite_Element_REF Gene_Symbol Chromosome Genomic_Coordinate TCGA-KL-8323-01A-21D-2312-05 TCGA-KL-8324-01A-11D-2312-05 TCGA-KL-8325-01A-11D-2312-05 cg00000027 RBL0 14 53468110 0.0545368833399913 0.635089208882213 0.0581022991274144 cg00000028 RBL1 15 53468111 0.0545366588241415 0.635089205024173 0.0581085373336217 cg00000029 RBL2 16 53468112 0.0545366588040571 0.635089205078394 0.0581085373332275 Expected output: Composite_Element_REF TCGA-KL-8323-01A-21D-2312-05 TCGA-KL-8324-01A-11D-2312-05 TCGA-KL-8325-01A-11D-2312-05 cg00000027 0.0545368833399913 0.635089208882213 0.0581022991274144 cg00000028 0.0545366588241415 0.635089205024173 0.0581085373336217 cg00000029 0.0545366588040571 0.635089205078394 0.0581085373332275
Asked by Anon (133 rep)
Nov 2, 2023, 09:30 PM
Last activity: Nov 5, 2023, 06:47 PM