views:

28

answers:

1

I have this :

ubuntu:~/tmp$ ls -l
total 4
drwxr-xr-x 2 abc abc 4096 2010-10-23 14:13 dir1
lrwxrwxrwx 1  abc abc  4 2010-10-23 14:13 dirln -> dir1

dir1 is empty

I want to rename dir1 to dir2 via dirln, like this:

ubuntu:~/tmp$ mv dirln/ dir2
mv: cannot move `dirln/' to `dir2': Not a directory

This gives error.

Can I rename a directory via its symlink ?

Thanks

A: 

You can use something like this:

mv "$(readlink -f dirln)" dir2

Note that this breaks the symbolic link, since it will now point to the old location of the folder. So you'd have to recreate the link.

(I didn't test the -f option, since it doesn't exist on Mac OS X.)

John Calsbeek
That worked. I did `mv `readlink -f dirln` dir2`. Thanks
abc