当涉及到 ls 时,Linux shell 不会打印最新信息。例如,我使用我的其他进程(IDE 等)来创建一些目录。但是,当我运行 ls 命令时,我看不到这些目录。该目录通常需要几秒钟有时几分钟才能出现在 ls 输出中。
怎么了?我可以强制刷新吗?理想情况下,当我说“ls”时,我想查看键入命令时的状态,而不是某些缓存结果。
文件系统不是 NFS 共享。我唯一能想到的另一件事是该目录是在从 Eclipse 运行时由程序创建的(并且显示被路由到我的本地窗口框)
我不知道这会如何影响事情?
Sté*_*las 14
ls与bash或任何外壳无关。它.通过从内核请求该列表来列出目录的内容,排除隐藏文件(名称以 a 开头的文件)
如果ls没有显示它们,那么它们就不存在(就操作系统而言)或者您列出了错误的目录。
例如,当当前目录在您脚下被重命名时,就会发生这种情况。喜欢:
$ pwd
/tmp/1
$ ls
x
$ mv /tmp/1 /tmp/2
$ pwd
/tmp/1 # (/tmp/1 has been renamed but the shell is not aware of it)
$ mkdir /tmp/1
$ touch /tmp/1/y
$ pwd
/tmp/1
$ ls # (ls is still listing `.` which has not changed, but now is a hardlink to `/tmp/2`, while `/tmp/1` is some new directory)
x
$ pwd -P # (double check what the current directory is)
/tmp/2
$ cd /tmp/1
$ ls
y
Run Code Online (Sandbox Code Playgroud)