OK got you now.
Looking in /usr/lib on my AS3 system I'll use libz.so.1.1.4 for example.
To see all the files that are related to libz.so.1.1.4
Code:
ls -l |grep libz.so.1.1.4
lrwxr-xr-x 1 root root 13 Aug 3 2005 libz.so -> libz.so.1.1.4
lrwxr-xr-x 1 root root 13 Aug 3 2005 libz.so.1 -> libz.so.1.1.4
-rwxr-xr-x 1 root root 52584 Sep 17 2003 libz.so.1.1.4
To get just the ones that are links you do it with:
Code:
ls -l |grep libz.so.1.1.4 |grep ^l
lrwxr-xr-x 1 root root 13 Aug 3 2005 libz.so -> libz.so.1.1.4
lrwxr-xr-x 1 root root 13 Aug 3 2005 libz.so.1 -> libz.so.1.1.4
In the above the grep for ^l (ell) tells it to look for an l in the first position as only a symbolic link would have that.
To get the name of the file that was linked do this:
Code:
ls -l |grep libz.so.1.1.4 |grep ^l |cut -c57- |awk '{print $1}'
libz.so
libz.so.1
The "cut -c57-" says to get everything from position 57 to end of line. This would be the file name and the file to which it is linked along with the "->". The reason to do cut rather than awk is that it will be position 57 regardless of whether the date on the file is a full date or just a time stamp but the number of fields in a file (as seen by awk) would vary if it were a date rather than a time stamp. (Note this position is consistent within an operating system but can be different from one OS to the next so you should always count to be sure of the number.) Once the cut is done you do awk to get only the first part of the output from the cut which is the file name. Here the opposite is true - the position varies but the field count doesn't so this is why awk is appropriate here.