打开终端并使用以下命令:
ls -l > yourfile.txt
Run Code Online (Sandbox Code Playgroud)
http://www.tuxfiles.org/linuxhelp/iodirection.html
如果你想要把只有一些文件的大小foo在文本文件中out.txt,你或许会
ls -l foo | awk '{print $5}' > out.txt
Run Code Online (Sandbox Code Playgroud)
并且还有许多其他变体(例如使用cut代替awk或stat代替ls等).
在shell脚本或终端上,您可以VAR使用例如将该大小分配给某个变量
VAR=$(ls -l foo | awk '{print $5}')
Run Code Online (Sandbox Code Playgroud)
如果您对ls普通重定向的所有输出都表示满意ls -l foo > out.txt就足够了,正如其他人所回答的那样.