Get total size of a list of files in UNIX

You should simply be able to pass $file_list to du:

du -ch $file_list | tail -1 | cut -f 1

du options:

  • -c display a total
  • -h human readable (i.e. 17M)

du will print an entry for each file, followed by the total (with -c), so we use tail -1 to trim to only the last line and cut -f 1 to trim that line to only the first column.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)