LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   make a script! (https://www.linuxquestions.org/questions/programming-9/make-a-script-286148/)

okeyla 02-04-2005 07:51 AM

make a script!
 
There is a file with the contain:

A: /usr/bin/A 100k
B: /usr/share/B 200k
C: /usr/local/src/C 150k

P.S. A,B,C are files

I wanna write a script ,
making the same directory structure with that.
And A,B,C files are at their mapping place.

Could somebody tells me how???

Below is my thinking...
===

#!/bin/bash

contain=`cat file`

for i in contain;do
mkdir...cp ... <--- I am annoying~~~ >_<
done

Please give me a hand!

Best Regards,
Diego

keefaz 02-04-2005 08:20 AM

You provided the destination path for A, B, C files but not the source path...
I mean when you copy a file, it is like :
cp source_file destination_path

now for mkdir :
Code:

#!/bin/bash

for file in $(cat file | cut -d' ' -f2); do
    dir=$(dirname $file)
    # create dir if it does not exist
    [ ! -d $dir ] && mkdir -p $dir
done


okeyla 02-04-2005 09:11 AM

Quote:

Originally posted by keefaz
You provided the destination path for A, B, C files but not the source path...
I mean when you copy a file, it is like :
cp source_file destination_path

now for mkdir :
Code:

#!/bin/bash

for file in $(cat file | cut -d' ' -f2); do
    dir=$(dirname $file)
    # create dir if it does not exist
    [ ! -d $dir ] && mkdir -p $dir
done


hmm... i will try it! ^_^
Actually , my goal is to extract the necessary library files for an application.
"ldd application" <--- shows so many relative library files for the application.
I would like to collect them , and put them into the relevent directory.

Here comes another question:
some libraries are sybolic links....
What's the next step?

keefaz 02-04-2005 09:32 AM

I don't get it... If ldd does not show unresolved shared library links, the linked libraries are
in the right place, why do you want to move them ?

okeyla 02-04-2005 09:38 AM

Quote:

Originally posted by keefaz
I don't get it... If ldd does not show unresolved shared library links, the linked libraries are
in the right place, why do you want to move them ?

Because i want to pack it and move to my embed linux system.
^_^

keefaz 02-04-2005 10:11 AM

It is better to compile programs statically in this case (gcc -static option or ./configure options)
this way, the program has library code built into it

okeyla 02-04-2005 07:45 PM

Quote:

Originally posted by keefaz
It is better to compile programs statically in this case (gcc -static option or ./configure options)
this way, the program has library code built into it

But,sometimes it came from the public field.
One is for convenience , the other is for practicing skills.
^_^

bigearsbilly 02-07-2005 06:04 AM

Code:

cd /usr/
find bin share local | cpio -pd  /bla/blah/HERE

'


All times are GMT -5. The time now is 06:25 AM.