linux - 在 Unix shell 中添加一列数字

给定 files.txt 中的文件列表,我可以像这样得到它们的大小列表:

cat files.txt | xargs ls -l | cut -c 23-30

产生这样的东西:

  151552
  319488
 1536000
  225280

我怎样才能得到所有这些数字的总数

最佳答案

... | paste -sd+ - | bc

是我找到的最短的一个(来自 UNIX Command Line 博客)。

编辑:为可移植性添加了 - 参数,感谢@Dogbert 和@Owen。

https://stackoverflow.com/questions/926069/

相关文章:

python - 找出 Python 中的对象正在使用多少内存

python - 如何让 IntelliJ 识别常见的 Python 模块?

linux - bash 中是否有 "goto"语句?

python - 如何使用子图更改图形大小?

python - 如何使用python解析包含毫秒的时间字符串?

linux - 如何卸载繁忙的设备

linux - 在 Linux 上开始使用 Latex

linux - 执行命令而不将其保留在历史记录中

linux - 如何使用 Bash 脚本自动添加用户帐户和密码?

python - 如何 pip 安装具有最小和最大版本范围的软件包?