Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Linking
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Highlands
Guru
Guru


Joined: 22 Apr 2003
Posts: 366
Location: Sundsvall, Sweden

PostPosted: Thu Jun 26, 2003 11:57 am    Post subject: Linking Reply with quote

If I have a file that is linked to another file, how do I change so that the file links to another file?
Like this

file1 links to file2

I want to change so that

file1 links to file3


What command do I use?
_________________
If Windows is the answer, you don't understand the question!
http://counter.li.org/cgi-bin/certificate.cgi/339446
Back to top
View user's profile Send private message
uxbod
Guru
Guru


Joined: 30 Dec 2002
Posts: 474
Location: UK

PostPosted: Thu Jun 26, 2003 12:07 pm    Post subject: Reply with quote

man unlink
Back to top
View user's profile Send private message
The Khan Artist
Apprentice
Apprentice


Joined: 21 Jan 2003
Posts: 210
Location: Texas, USA

PostPosted: Thu Jun 26, 2003 2:21 pm    Post subject: Reply with quote

rm file1
ln /path/file1 /path/file3
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Thu Jun 26, 2003 2:41 pm    Post subject: Reply with quote

The first argument should be the source file and the second the destination (link).
The Khan Artist wrote:

ln /path/file1 /path/file3


So the command should actually be:
Code:

ln /path/file3 /path/file1


Simply doing:
Code:

ln -f /path/file3 /path/file1

or
Code:

ln -sf /path/file3 /path/file1

will also work and will not need the 'rm' step in between (be very careful however not to get your arguments reversed when using a -f argument).
Back to top
View user's profile Send private message
Highlands
Guru
Guru


Joined: 22 Apr 2003
Posts: 366
Location: Sundsvall, Sweden

PostPosted: Thu Jun 26, 2003 3:16 pm    Post subject: Reply with quote

okay, thanks :)

one more thing
how do i copy a file that i linking to a file?
I dont want to copy the target , just the lnk..
_________________
If Windows is the answer, you don't understand the question!
http://counter.li.org/cgi-bin/certificate.cgi/339446
Back to top
View user's profile Send private message
The Khan Artist
Apprentice
Apprentice


Joined: 21 Jan 2003
Posts: 210
Location: Texas, USA

PostPosted: Thu Jun 26, 2003 3:33 pm    Post subject: Reply with quote

Blarg. I don't use ln much, and I almost always forget that. But I was sure I had it right this time. :P

Naan Yaar wrote:
The first argument should be the source file and the second the destination (link).
The Khan Artist wrote:

ln /path/file1 /path/file3


So the command should actually be:
Code:

ln /path/file3 /path/file1


Simply doing:
Code:

ln -f /path/file3 /path/file1

or
Code:

ln -sf /path/file3 /path/file1

will also work and will not need the 'rm' step in between (be very careful however not to get your arguments reversed when using a -f argument).
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Thu Jun 26, 2003 5:45 pm    Post subject: Reply with quote

Code:

cp -d <source> <target>

will copy symlinks correctly. It will sort of work with hardlinks, but it is probably better to recreate the hardlink than use cp. 'man cp' for more details.
Highlands wrote:

how do i copy a file that i linking to a file?
I dont want to copy the target , just the lnk..
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum