macos 如何删除符号链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7932906/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:33:08  来源:igfitidea点击:

How do I remove a symlink?

macossymlink

提问by locoboy

i just created the symlink sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dyliband am wondering how i get rid of it if I wanted to. How would i do this?

我刚刚创建了符号链接sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib,想知道如果我想如何摆脱它。我该怎么做?

回答by Marc B

Remove it just like you would any other file: rm /usr/lib/libmysqlclient.18.dylib. rm will remove the symlink itself, not the file the link is pointing at.

像删除任何其他文件一样删除它:rm /usr/lib/libmysqlclient.18.dylib. rm 将删除符号链接本身,而不是链接指向的文件。

回答by AlecRust

You could also use the unlink command: unlink /path/to/sym/link

您还可以使用 unlink 命令: unlink /path/to/sym/link

I believe just deleting the file within Finder works fine also, it will have a little shortcut icon on it.

我相信在 Finder 中删除文件也可以正常工作,它上面会有一个小快捷图标。

回答by Mohammad Anini

Just run:

赶紧跑:

rm /usr/lib/libmysqlclient.18.dylib

This will remove the file (i.e. the symlink).

这将删除文件(即符号链接)。

Alternatively you may use unlink:

或者,您可以使用取消链接:

unlink /usr/lib/libmysqlclient.18.dylib

回答by Sherif SALEH

I had a link pointing to a folder with short-name "testproject": you make that with this command

我有一个链接指向一个短名称为“testproject”的文件夹:你用这个命令

ln -s /Users/SHERIF/repo/test  testproject

I had to change the folder name to something else for some reasons when I run the command unlink pointing to the old folder directory it didn't work.

当我运行指向旧文件夹目录的命令 unlink 时,由于某些原因,我不得不将文件夹名称更改为其他名称,但它不起作用。

I tried to only unlink testprojectto remove the short-name so I can re-use the same name again and link to the newly named folder. it did work fine for me.

我试图只unlink testproject删除短名称,以便我可以再次使用相同的名称并链接到新命名的文件夹。它确实对我有用。

回答by Pip

Somehow I had a symlink to a non-existing folder. Have no idea how it happened but to remove it I found the easiest way was open in finder and manually delete it. I came to this decision after an hour wasted on trying to delete it with the Terminal.

不知何故,我有一个指向不存在文件夹的符号链接。不知道它是怎么发生的,但要删除它,我发现最简单的方法是在 finder 中打开并手动删除它。在尝试使用终端删除它浪费了一个小时后,我做出了这个决定。

回答by Basile Starynkevitch

You could remove that link with sudo rm /usr/lib/libmysqlclient.18.dylib

您可以删除该链接 sudo rm /usr/lib/libmysqlclient.18.dylib