Bash Expansion 路径名展开, 如果是输入字符串,怎么办?

2019-09-06 18:30:23 +08:00
 gIrl1990

see: https://blog.wentao.me/the-linux-command-line/2014/05/09/bash-expansion.html

bash-3.2$ read
~/.bash_profile
bash-3.2$ echo "$REPLY"
~/.bash_profile
bash-3.2$ ls $REPLY
ls: ~/.bash_profile: No such file or directory
bash-3.2$ ls "$REPLY"
ls: ~/.bash_profile: No such file or directory

如何让这个目录展开?

973 次点击
所在节点    问与答
2 条回复
ps1aniuge
2019-09-06 18:39:54 +08:00
powershell on linux:

PS /root> $REPLY='~/.bash_profile'
PS /root> ls $REPLY
/root/.bash_profile
PS /root> ls -l $REPLY
-rw-r--r--. 1 root root 176 12 月 29 2013 /root/.bash_profile
PS /root>
conanforever22
2019-09-06 18:50:32 +08:00
ls `eval echo $REPLY`

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/598683

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX