The TPM of a gene is simply the sum of the TPMs of the transcripts.
What you need is a table mapping the transcript_ids to gene symbols, and a simple, group, summerise(sum) operation.
The easiest way to do this would be to use R, dplyr and the "EnsDb" pacakges (for example, EnsDb.Hsapiens.v86. This is a bit out of date now and there is probably a more recent one)
Then you would do something like:
library(EnsDb.Hsapiens.v86)
library(dplyr)
salmon_output = read.delim("quant.sf")
tx2gene = transcripts(EnsDb.Hsapiens.v86,
columns=c("tx_id", "gene_name", "gene_id"),
return.type="DataFrame")
gene_tpms <- salmon_output %>%
inner_join(tx2gene, by=c("Name"="tx_id")) %>%
group_by(gene_id, gene_name) %>%
summerise(TPM=sum(TPM))
If you REALLY wanted to do it from the GTF, then you'd need to extract a list of transcript_ids and symbols from the GTF. I guess some thing like:
grep gene_name ensembl.gtf \
| grep transcript_id \
| sed -E 's/.+transcript_id \"(ENST[0-9]+)\";.*gene_name \"([^\"]+)\";.+/\1\t\2/' > tx2gene.tev
would do the trick, and then use dplyr to sum it like above.