Bash Tilde扩展(Bash Tilde Expansion)

编程入门 行业动态 更新时间:2024-10-18 16:51:38
Bash Tilde扩展(Bash Tilde Expansion)

是否可以添加bash用于代字符扩展的规则? 我希望〜数据扩展到/ data / users / me,〜scratch扩展到/ data / scratch / me等等。这是可能的吗,还是bash对'〜'的严格控制太紧?

谢谢,

安德鲁

Is it possible to add to the rules that bash uses for tilde expansion? I'd like to have ~data expand to /data/users/me, ~scratch expand to /data/scratch/me etc.. Is this possible, or does bash have too tight a tight hold on the '~'?

Thanks,

Andrew

最满意答案

Tilde扩展绑定到用户的主目录(或目录堆栈的内容或$PWD或$OLDPWD )。 使用可变扩展,别名或函数来完成你所追求的内容。 您还可以使用CDPATH列出cd的目录以查找目标目录。

Tilde expansion is tied to users' home directories (or the contents of the directory stack or $PWD or $OLDPWD). Use variable expansion, aliases or functions to accomplish what you're after. You can also use CDPATH to list a set of directories for cd to look in for destination directories.

更多推荐

本文发布于:2023-07-23 18:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1235650.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Bash   Tilde   Expansion

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!