Using du -h: how to sum up the file size of file1, file 2, file 3...located in various directories.
I believe it can be done via script, but I have no idea how to perform arithmetic out of different outputs in the terminal.
Use the -c
/ --total
option to get the total size.
To get the last line containing the "total" value:
du -hc /path/to/file1 /path/to/file2 /path/to/filex | tail -n1
Or the last line without the "total" string:
du -hc /path/to/file1 /path/to/file2 /path/to/filex | tail -n1 | cut -f1
du -ach ./.cache/pip/selfcheck.json Downloads/PDFMaker1.0.1.tar
I get a total in the last line. (36K total)