Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 10/05/2012, à 14:41

®om

[Résolu] ln -sf et les répertoires…

Pour écraser un lien symbolique pour le faire pointer sur autre chose, on peut utiliser l'option -f de ln.
Mais si ça fonctionne bien pour les fichiers, il semble y avoir un bug avec les répertoires.

Un terminal vaut mieux qu'un long discours :

rom@laptop:/tmp/testln$ touch a b
rom@laptop:/tmp/testln$ ln -s a x
rom@laptop:/tmp/testln$ ls -l
total 0
-rw-rw-r-- 1 rom rom 0 2012-05-10 14:36 a
-rw-rw-r-- 1 rom rom 0 2012-05-10 14:36 b
lrwxrwxrwx 1 rom rom 1 2012-05-10 14:36 x -> a
rom@laptop:/tmp/testln$ ln -sf b x
rom@laptop:/tmp/testln$ ls -l
total 0
-rw-rw-r-- 1 rom rom 0 2012-05-10 14:36 a
-rw-rw-r-- 1 rom rom 0 2012-05-10 14:36 b
lrwxrwxrwx 1 rom rom 1 2012-05-10 14:36 x -> b
rom@laptop:/tmp/testln$ mkdir c d
rom@laptop:/tmp/testln$ ln -sf c x
rom@laptop:/tmp/testln$ ls -l
total 8
-rw-rw-r-- 1 rom rom    0 2012-05-10 14:36 a
-rw-rw-r-- 1 rom rom    0 2012-05-10 14:36 b
drwxrwxr-x 2 rom rom 4096 2012-05-10 14:37 c
drwxrwxr-x 2 rom rom 4096 2012-05-10 14:37 d
lrwxrwxrwx 1 rom rom    1 2012-05-10 14:37 x -> c
rom@laptop:/tmp/testln$ ln -sf d x
rom@laptop:/tmp/testln$ ls -l
total 8
-rw-rw-r-- 1 rom rom    0 2012-05-10 14:36 a
-rw-rw-r-- 1 rom rom    0 2012-05-10 14:36 b
drwxrwxr-x 2 rom rom 4096 2012-05-10 14:37 c
drwxrwxr-x 2 rom rom 4096 2012-05-10 14:37 d
lrwxrwxrwx 1 rom rom    1 2012-05-10 14:37 x -> c

La dernière ligne devrait être :

lrwxrwxrwx 1 rom rom    1 2012-05-10 14:37 x -> d

Qu'en pensez-vous ?

Dernière modification par ®om (Le 10/05/2012, à 17:21)

Hors ligne

#2 Le 10/05/2012, à 15:42

dev/random

Re : [Résolu] ln -sf et les répertoires…

®om a écrit :
rom@laptop:/tmp/testln$ ln -sf d x
rom@laptop:/tmp/testln$ ls -l
total 8
-rw-rw-r-- 1 rom rom    0 2012-05-10 14:36 a
-rw-rw-r-- 1 rom rom    0 2012-05-10 14:36 b
drwxrwxr-x 2 rom rom 4096 2012-05-10 14:37 c
drwxrwxr-x 2 rom rom 4096 2012-05-10 14:37 d
lrwxrwxrwx 1 rom rom    1 2012-05-10 14:37 x -> c

La dernière ligne devrait être :

lrwxrwxrwx 1 rom rom    1 2012-05-10 14:37 x -> d

Qu'en pensez-vous ?

Essaye:

$ ln -sf -T d x

Plus d'infos dans le man ou mieux, "info ln" :

`-T'
`--no-target-directory'
     Do not treat the last operand specially when it is a directory or a
     symbolic link to a directory.  *Note Target directory::.

667, the neighbour of the beast..

Hors ligne

#3 Le 10/05/2012, à 17:21

®om

Re : [Résolu] ln -sf et les répertoires…

Effectivement. J'avais pourtant survolé le man, et en lisant trop vite je pensais que cette option ne correspondait pas à ce que je voulais.

Merci.

$ ln -sfT d x

Hors ligne