LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2005, 07:51 AM   #1
okeyla
Member
 
Registered: Nov 2004
Posts: 47

Rep: Reputation: 15
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
 
Old 02-04-2005, 08:20 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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
 
Old 02-04-2005, 09:11 AM   #3
okeyla
Member
 
Registered: Nov 2004
Posts: 47

Original Poster
Rep: Reputation: 15
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?
 
Old 02-04-2005, 09:32 AM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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 ?
 
Old 02-04-2005, 09:38 AM   #5
okeyla
Member
 
Registered: Nov 2004
Posts: 47

Original Poster
Rep: Reputation: 15
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.
^_^
 
Old 02-04-2005, 10:11 AM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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
 
Old 02-04-2005, 07:45 PM   #7
okeyla
Member
 
Registered: Nov 2004
Posts: 47

Original Poster
Rep: Reputation: 15
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.
^_^
 
Old 02-07-2005, 06:04 AM   #8
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Code:
cd /usr/
find bin share local | cpio -pd  /bla/blah/HERE
'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can i make a script or program make a phone call? nephish Linux - Software 2 08-15-2005 09:02 PM
Need to make a start up script chr0no Mandriva 4 08-05-2004 10:46 AM
How to make a GUI for a Script oldstinkyfish Programming 5 07-25-2004 03:18 AM
need help in trying to make a script marsonist Linux - Software 8 10-15-2002 09:23 AM
Anyone know how to make a script that will ... kato678 Programming 4 07-19-2002 05:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration