ln option(s) to replace existing symlink
by Skaperen from LinuxQuestions.org on (#5K47V)
what is/are the ln option(s) to replace an existing symlink with a new one that points to an existing directory? i thought it would be -fs as in ln -fs what_to_point_to symlink_name. yet, when i do it, it follows the symlink to be replaced and creates a symlink in the previous directory with the name of the new one pointing to itself (as if i had been in the old directory). i was expecting it to behave as the man page described (to "remove existing destination", foo in this example).
Code:lt2a/forums /home/forums 22> ls -dl old new foo
/bin/ls: cannot access 'old': No such file or directory
/bin/ls: cannot access 'new': No such file or directory
/bin/ls: cannot access 'foo': No such file or directory
lt2a/forums /home/forums 23> mkdir -v old new
/bin/mkdir: created directory 'old'
/bin/mkdir: created directory 'new'
lt2a/forums /home/forums 24> ln -fsv old foo
'foo' -> 'old'
lt2a/forums /home/forums 25> ls -dl old new foo
lrwxrwxrwx 1 forums forums 3 Jun 15 19:30 foo -> old
drwxr-xr-x 2 forums forums 4096 Jun 15 19:30 new
drwxr-xr-x 2 forums forums 4096 Jun 15 19:30 old
lt2a/forums /home/forums 26> ln -fsv new foo
'foo/new' -> 'new'
lt2a/forums /home/forums 27> ls -dl old new foo
lrwxrwxrwx 1 forums forums 3 Jun 15 19:30 foo -> old
drwxr-xr-x 2 forums forums 4096 Jun 15 19:30 new
drwxr-xr-x 2 forums forums 4096 Jun 15 19:31 old
lt2a/forums /home/forums 28> ls -Al old
total 0
lrwxrwxrwx 1 forums forums 3 Jun 15 19:31 new -> new
lt2a/forums /home/forums 29>is ln broken?
Code:lt2a/forums /home/forums 22> ls -dl old new foo
/bin/ls: cannot access 'old': No such file or directory
/bin/ls: cannot access 'new': No such file or directory
/bin/ls: cannot access 'foo': No such file or directory
lt2a/forums /home/forums 23> mkdir -v old new
/bin/mkdir: created directory 'old'
/bin/mkdir: created directory 'new'
lt2a/forums /home/forums 24> ln -fsv old foo
'foo' -> 'old'
lt2a/forums /home/forums 25> ls -dl old new foo
lrwxrwxrwx 1 forums forums 3 Jun 15 19:30 foo -> old
drwxr-xr-x 2 forums forums 4096 Jun 15 19:30 new
drwxr-xr-x 2 forums forums 4096 Jun 15 19:30 old
lt2a/forums /home/forums 26> ln -fsv new foo
'foo/new' -> 'new'
lt2a/forums /home/forums 27> ls -dl old new foo
lrwxrwxrwx 1 forums forums 3 Jun 15 19:30 foo -> old
drwxr-xr-x 2 forums forums 4096 Jun 15 19:30 new
drwxr-xr-x 2 forums forums 4096 Jun 15 19:31 old
lt2a/forums /home/forums 28> ls -Al old
total 0
lrwxrwxrwx 1 forums forums 3 Jun 15 19:31 new -> new
lt2a/forums /home/forums 29>is ln broken?