View previous topic :: View next topic |
Author |
Message |
Highlands Guru
Joined: 22 Apr 2003 Posts: 366 Location: Sundsvall, Sweden
|
Posted: Thu Jun 26, 2003 11:57 am Post subject: Linking |
|
|
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 |
|
|
uxbod Guru
Joined: 30 Dec 2002 Posts: 474 Location: UK
|
Posted: Thu Jun 26, 2003 12:07 pm Post subject: |
|
|
man unlink |
|
Back to top |
|
|
The Khan Artist Apprentice
Joined: 21 Jan 2003 Posts: 210 Location: Texas, USA
|
Posted: Thu Jun 26, 2003 2:21 pm Post subject: |
|
|
rm file1
ln /path/file1 /path/file3 |
|
Back to top |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Thu Jun 26, 2003 2:41 pm Post subject: |
|
|
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 |
|
|
Highlands Guru
Joined: 22 Apr 2003 Posts: 366 Location: Sundsvall, Sweden
|
Posted: Thu Jun 26, 2003 3:16 pm Post subject: |
|
|
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 |
|
|
The Khan Artist Apprentice
Joined: 21 Jan 2003 Posts: 210 Location: Texas, USA
|
Posted: Thu Jun 26, 2003 3:33 pm Post subject: |
|
|
Blarg. I don't use ln much, and I almost always forget that. But I was sure I had it right this time.
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 |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Thu Jun 26, 2003 5:45 pm Post subject: |
|
|
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 |
|
|
|