Zeb Packard wrote:
> On 1/20/07, Nadav Vinik <[EMAIL PROTECTED]> wrote:
>   
>> Do you have script like that?
>>
>> since It user readable but it harder to parse in simple regular expression:
>>
>> $ ldd /bin/bash
>>        linux-gate.so.1 =>  (0xffffe000)
>>        libreadline.so.5 => /lib/libreadline.so.5 (0xb7f6c000)
>>        libhistory.so.5 => /lib/libhistory.so.5 (0xb7f64000)
>>        libncurses.so.5 => /lib/libncurses.so.5 (0xb7f22000)
>>        libdl.so.2 => /lib/libdl.so.2 (0xb7f1e000)
>>        libc.so.6 => /lib/libc.so.6 (0xb7df4000)
>>        /lib/ld-linux.so.2 (0xb7fb7000)
>>     
>
> No I don't but,
Without understanding why you want this, a quick stab with (g)awk and 
sed leads to:

$ ldd `which bash` | sed -e 's/([^ ]*)//' -e 's/ //g' | awk -F=\> 
'$2!="" {print $2}'
/lib/libtermcap.so.2
/lib/libdl.so.2
/lib/libc.so.6

Where /lib/ld-linux.so.2 and linux-gate.so.1 are ignored.

The first sed expression removes the (0xb7f6c000) part.
The second sed expression removes whitespace (so you don't get blank 
lines with awk later).
The awk -F=\> specifies a field separator of => (the default is " ").
The rest of the awk will show the second term of an input line split by 
=> (ie. the bit we want), if this is not empty

I'm no sed/awk guru so it might be possible to clean this up, although 
as it is, for me, this qualifies as a "one-liner" :)

If you want the output to be alphabetical pipe the above to `sort`.

If you want this in a script (with sorting) try:

#!/bin/bash

LDD=/usr/bin/ldd
SED=/bin/sed
AWK=/usr/bin/awk
SORT=/bin/sort

if [ -r "$1" ]; then
    $LDD $1 | $SED -e 's/([^ ]*)//' -e 's/ //g' | $AWK -F=\> '$2!="" 
{print $2}' | $SORT
fi

Where the if [ -r "$1" ] bit checks if the argument passed to the script 
is a readable file.

HTH

Amadeus
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page

Reply via email to