[Nottingham] bash script help

Godfrey Nix godfrey at gnnix.co.uk
Wed Aug 17 19:38:56 BST 2005


On Wed, 2005-08-17 at 19:07, Brian Pickford wrote:
> Hi all, I was wondering if any talented scripters in the group could 
> write a script for me please?
> 
> I need to take the output of a ldd and copy all the listed files ot a 
> single location:
> 
> ldd digikam
> digikam:
> libdigikam.so.0 => not found (0x0)
> libgdbm.so.3 => /usr/local/lib/libgdbm.so.3 (0x28082000)
> libkipi.so.0 => not found (0x0)

How about this then ?

ldd digikam | grep '=>' | grep -v 'not found' | awk '{print $3}' \
xargs -i cp {} /path/to/dest/lib

For those that do not have familiarity with bash scripting, read on.
Every one else - tough !

The two grep commands make sure we have an existing library file
located, the awk command takes the path to the file and gives a simple
list of full filenames, then the xargs repeats the command given (this
case it is 'cp') on each file. The {} stand for each file in the list.

Sorry I cannot make the meeting tonight. Drat! Off work with suspected
sciatica !!?!

Have fun

Godfrey



More information about the Nottingham mailing list