如果你要打印的文件夹内容的一个漂亮的树和它的子文件夹,您可以使用“树”。
如果这不是你的系统上安装,你必须这样做第一:
sudo apt-get install tree
那么语法是非常简单的。如果你想输出保存到一个文件:
tree -h -A path/to/dir > output.txt
-A
用于确保输出使用ASCII字符。
-h
将以人们可读的格式打印每个文件大小。
您有更多的选择来限制输出,您可以通过使用“--help”选项得到:
> tree --help
-a All files are listed.
-d List directories only.
-l Follow symbolic links like directories.
-f Print the full path prefix for each file.
-L level Descend only level directories deep.
-o filename Output to file instead of stdout.
-s Print the size in bytes of each file.
-h Print the size in a more human readable way.
--dirsfirst List directories before files (-U disables).
感谢sharpner,就像一个魅力。怎么打印文件大小? – Jim 2011-03-23 16:37:52
ls -la或-ls -lach不管你看起来不错 – sharpner 2011-03-23 16:38:42
对不起,但我不明白。如果[$#-gt 0];然后 ls $ 1> textfile.txt ls -la不能按我想要的方式工作。我想有filename1 size1(在第一行)filename2 size2(在第二行)等...对不起,所有的麻烦 – Jim 2011-03-23 16:44:51