views:

60

answers:

2

I am trying to extract the value from

in File.txt :

116206K->13056K(118080K), 0.0879950 secs][Tenured:274796K->68056K(274892K), 0.2713740 secs] 377579K->68056K(392972K), [Perm :17698K->17604K(17920K)], 0.3604630 secs]

I have try to extract

cat File.txt | grep 'Perm '| cut -d',' -f3|cut -d'(' -f2 |cut -d')' -f 1

What is wrong here . because i am trying I am getting the

392972K which is from 377579K->68056K(392972K)

But i should get from [Perm :17698K->17604K(17920K)] 17920

+3  A: 

One quick fix, change -f3 to -f4 as the field you need appears after the 3rd comma:

cat File.txt | grep 'Perm '| cut -d',' -f4|cut -d'(' -f2 |cut -d')' -f 1
                                        ^^

You can also use sed as:

grep 'Perm' File.txt | sed -r 's/.*Perm :.*\((.*?)\).*/\1/'

Working link

codaddict
A: 
$ awk -vFS="->" '{gsub(/)].*|.*\(/,"",$5);print $5}' file1
17920K
ghostdog74