问题描述
创建符号链接时,符号链接占用的字节数恰好是它指向的原点的长度.例如,
When we create a symlink, the number of bytes the symlink takes up is exactly the length of the origin it points to. For instance,
$ ln -s dest link1
$ ln -s longer_dest link2
$ ls -l
lrwxrwxrwx 1 username 4 Mar 26 20:21 link1 -> dest
lrwxrwxrwx 1 username 11 Mar 26 20:21 link2 -> longer_dest
其中 link1
占用4个字节,即 dest
的长度; link2
占用11个字节,即 longer_dest
的长度.因此,符号链接实际上只不过是存储在纯文本中的目标路径.因此,我想知道是否可以在文本编辑器(最好是Emacs)中编辑符号链接(目的地).我搜索了一段时间,找不到任何人在谈论这个.请注意,这个问题纯粹是出于好奇.我很清楚,我可以通过 ln -f -s
覆盖符号链接.
where link1
takes up 4 bytes, which is the length of dest
; link2
takes up 11 bytes, which is the length of longer_dest
. Therefore, symlinks are in fact no more than the destination path stored in plain text. So I am wondering if it is possible to edit (the destination) of a symlink in text editors, preferably Emacs. I googled for a while and couldn't find anyone talking about this. Note that this question is purely out of curiosity; I know full well that I can overwrite a symlink by ln -f -s
.
推荐答案
是的,在Emacs中,这可以在Dired模式下实现,特别是wdired(可写Dired)模式.
Yes, in Emacs this is possible in dired-mode, specifically wdired (writable dired) mode.
请注意,dired和wdired都是内置程序包.
Note, dired and wdired both are built-in packages.
这是一个例子...
(顺便说一句:我正在使用 Smex 为Emacs提供 Mx
命令搜索并执行更符合人体工程学的UI +模糊匹配)
(BTW: I'm using Smex to give Emacs M-x
command search & execute a more ergonomic UI + fuzzy matching)
这篇关于是否可以使用文本编辑器编辑符号链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!