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-13-2005, 09:31 PM   #1
okeyla
Member
 
Registered: Nov 2004
Posts: 47

Rep: Reputation: 15
copy both soft link and its linked file


As title , if i wanna do it by bash script , how to do that?
For example ,
I want to copy /usr/lib/libfreetype.so to somewhere.
But it is a soft link , linking to /usr/lib/libfreetype.6.3.2
What i desire is using a script to copy both of them to the destination and
keeping its linking relation.

===
P.S.
cp -L
cp -av
those two commands' parameter cannot satidfy me~

Best Regards,
Diego
 
Old 02-13-2005, 09:53 PM   #2
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
~/clean $ ls -l out
lrwxrwxrwx 1 user users 5 2005-02-13 22:42 out -> a.out

cp --no-dereference out ./test
cp a.out ./test

cd ./test
~/clean/test $ ls -l
-rwxr-xr-x 1 user users 8334 2005-02-13 22:47 a.out
lrwxrwxrwx 1 user users 5 2005-02-13 22:47 out -> a.out

if it gets more complex with long paths that need changing then just rm the link copy te file
and rebuild the link with ln -s
 
Old 02-13-2005, 11:15 PM   #3
okeyla
Member
 
Registered: Nov 2004
Posts: 47

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by foo_bar_foo
~/clean $ ls -l out
lrwxrwxrwx 1 user users 5 2005-02-13 22:42 out -> a.out

cp --no-dereference out ./test
cp a.out ./test

cd ./test
~/clean/test $ ls -l
-rwxr-xr-x 1 user users 8334 2005-02-13 22:47 a.out
lrwxrwxrwx 1 user users 5 2005-02-13 22:47 out -> a.out

if it gets more complex with long paths that need changing then just rm the link copy te file
and rebuild the link with ln -s
Thanks for sharing your idea.
But the point is...how do i do it by script program?

Just take your code as example:
Code:
usage:super_cp file destination
in the script , we could know if file link to other or not.
copy it / them  to the destination.
(Moreover , I find sometimes there's soft link to anohter soft link file!)
 
Old 02-13-2005, 11:30 PM   #4
okeyla
Member
 
Registered: Nov 2004
Posts: 47

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by foo_bar_foo
~/clean $ ls -l out
lrwxrwxrwx 1 user users 5 2005-02-13 22:42 out -> a.out

cp --no-dereference out ./test
cp a.out ./test

cd ./test
~/clean/test $ ls -l
-rwxr-xr-x 1 user users 8334 2005-02-13 22:47 a.out
lrwxrwxrwx 1 user users 5 2005-02-13 22:47 out -> a.out

if it gets more complex with long paths that need changing then just rm the link copy te file
and rebuild the link with ln -s
Thanks for sharing your idea.
But the point is...how do i do it by script program?

Just take your code as example:
Code:
usage:super_cp file destination
in the script , we could know if file link to other or not.
copy it / them  to the destination.
(Moreover , I find sometimes there's soft link to anohter soft link file!)
 
  


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
how to copy soft link hongxing Linux - Software 5 02-24-2010 07:14 AM
Soft Link and Hard Link Moataz Red Hat 1 04-25-2005 06:30 AM
Which do you prefer. Hard / soft copy text? unholy General 7 04-14-2004 05:37 PM
Copy File as a Link Gerardoj Linux - General 3 12-02-2003 10:34 PM
Soft link help Pyroknight Linux - Newbie 1 02-06-2003 06:21 PM

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

All times are GMT -5. The time now is 08:39 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