只需指定完整路径和模式:
ls -d -- "${txtpath}"/*.txt
Run Code Online (Sandbox Code Playgroud)
虽然实际上列表是由 shell globbing 完成的,但ls最终只是打印了它从 shell 接收到的参数。你不妨printf在这里使用:
printf '%s\n' "${txtpath}"/*.txt
Run Code Online (Sandbox Code Playgroud)
txt在目录中没有非隐藏文件的情况下,这将给出相同的结果,除了(在不匹配的 glob 时不取消命令的 shell 中)。
| 归档时间: |
|
| 查看次数: |
485 次 |
| 最近记录: |