linux - 在 shell 脚本中使用 ~/(user entry)

标签 linux bash shell fedora-25


我无法通过 shell 脚本访问“用户条目”,以下命令中断错误( ls: cannot access '~/Workspace': No such file or directory )

ls ~/Workspace
ls "~/Workspace"
ls "\~/Workspace"

通过终端命令上面的命令工作正常。有任何想法吗?
我使用的是 fedora 25,没有进行重大定制。谢谢。

最佳答案

您确定该用户的主目录中存在“工作区”目录吗?

无论如何,试试这个:

#!/bin/bash
ls $HOME/Workspace

关于linux - 在 shell 脚本中使用 ~/(user entry),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43801281/

相关文章:

linux - 我必须只获取文本文件中包含另一个目录中文件的文件名的那些行

bash - 用 cygwin 打开 chrome

bash - 如何监视两个进程并在一个进程退出时执行某些操作(bash 脚本)?

android - 如何从 shell 中退出 APK

linux - awk 第一列中的项目,然后再次 awk 使用第二列中的结果?

linux - Linux 的 Oracle JDK 链接是否断开?

macos - 在 Mac OS 上以毫秒为单位测量 shell 脚本执行时间

linux - 为什么 accountsservice 总是返回一个空的用户列表?

c - 如何制作可以在 gcc (Linux) 和 VS (Windows) 中编译的程序?

linux - 如何从 Windows Linux 子系统打开 VSCode?