abh
abh

Reputation: 101

Find the double quotes values and print them using awk

I have a file with 1000 rows in it

For example:

chr1        Cufflinks        transcript        34611        36081        1000        -        .        gene_id "FAM138A"; transcript_id "uc001aak.3"; FPKM "1.2028600217"; frac "1.000000"; conf_lo "0.735264"; conf_hi "1.670456"; cov "0.978610";

I want to search file and extract the values after string FPKM, like

"1.2028600217"

Can I do it using awk?

Upvotes: 0

Views: 138

Answers (2)

Ed Morton
Ed Morton

Reputation: 203664

You can use awk, but this is a simple substitution on a single line so sed is better suited:

$ cat file
chr1 Cufflinks transcript 34611 36081 1000 - . gene_id "FAM138A"; transcript_id "uc001aak.3"; FPKM "1.2028600217"; frac "1.000000"; conf_lo "0.735264"; conf_hi "1.670456"; cov "0.978610";
$ sed 's/.*FPKM *"\([^"]*\)".*/\1/' file
1.2028600217

Upvotes: 1

Kent
Kent

Reputation: 195089

if you don't care which column does the FPKM show in, you could:

grep -Po '(?<=FPKM )"[^"]*"' file

Upvotes: 1

Related Questions