psy
psy

Reputation: 331

How to extract shared library version from SONAME field?

There is a shared library say, libsample.so & libsample.so.abc.xy (a,b,c,x and y are 0-9), former having soft link to latter.

How to extract "abc.xy" field from SONAME section of libsample.so?

I have tried below command : $ objdump -p libsample.so | grep SONAME | awk {' print $2'} this prints : libsample.so.abc.xy

But how to further fetch "abc.xy"?

Upvotes: 0

Views: 410

Answers (1)

Kent
Kent

Reputation: 195229

sed

sed 's/.*\.so.//'

Test:

kent$  sed 's/.*\.so.//' <<<"foo.so.bar.so.so.we.want.this"
we.want.this

awk

 awk -F'so[.]' '{print $NF}'

Test:

kent$  awk -F'so[.]' '{print $NF}' <<<"foo.so.bar.so.so.we.want.this"
we.want.this

Upvotes: 1

Related Questions