How to use gnu utils to select one line from these three lines?

67 Views Asked by At

So basically I want to use this command to get the .plt section info.

readelf -S ELF_Binary | awk '/plt/ {print $2,$4,$5,$6} '

and the output is like this:

.rel.plt 08048b20 000b20 0001f0
.plt 08048d40 000d40 0003f0
.got.plt 08050ff4 007ff4 000104

So basically I only want to get the middle line, which is :

.plt 08048d40 000d40 0003f0

I tried several ways but I just cannot make it...

Could anyone give me some help?

1

There are 1 best solutions below

2
On BEST ANSWER

Instead of matching lines containing plt, say that you want the second field to be .plt:

readelf -S ELF_Binary | awk '$2==".plt" {print $2,$4,$5,$6}'