把文件夹清单导出成文本文件
把文件夹里有什么(名称、大小、日期)导出成一个纯文本清单。
运行 ls -la 文件夹 > file.txt,即可把详细清单写入文本文件。
01命令
命令
$ ls -la ~/Desktop/Project > ~/Desktop/filelist.txt02作用说明
> 重定向会把本该显示在屏幕上的清单写进文件;用 >> 则是追加而不是覆盖。想要包含子文件夹的完整递归清单,用 find . -type f > filelist.txt,做文件盘点或核对备份内容时很方便。
03风险
!注意: > 会不加询问地覆盖同名文件;想追加内容请用 >>。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- cp – Copy files依据: The shell redirection operator > writes a command's output to a file; ls -la formats the listing with details.
- find – Walk a file hierarchy依据: find . -type f can also list files recursively when you need every nested file, not just one level.
最后验证: 2026-09-18 · 分类: 文件与文件夹