开发者

How to rename a directory via its sysmlink?

I have this :

ubuntu:~/tmp$ ls -l
total 4开发者_StackOverflow中文版
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


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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜