thank you
your code extracted what I need in cmd, but how I can write the result in a txt file?
I have gtf file containing 7 columns from which i am going extract only gene name part from column 7th.
The 7th column contains some information including gene_id, gene_name and so on that I posted one row of column 7th below:
gene_id "XLOC_000001"; transcript_id "TCONS_00000001"; exon_number "1"; gene_name "NAC001"; oId "AT1G01010.1"; nearest_ref "AT1G01010.1"; class_code "="; tss_id
I need only gene_name from this column, for example "NAC001", how can I extract which I need please?
Sorry I missed the part that you only posted column 7 from your file. Either use @dschika's solution below or cut the 7th column and then use the one liner below.
$ awk -F ";" '{sub(/gene_name/,""); print $4}' your_file
If you don't need the quotes around the gene name
$ awk -F ";" '{sub(/gene_name/,""); print $4}' your_file | sed 's/"//g'
Log in to answer this question.