Timeline for How can I get the size of a file in a bash script?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 2, 2019 at 10:00 | review | Low quality posts | |||
| Oct 2, 2019 at 11:31 | |||||
| Apr 12, 2017 at 5:53 | comment | added | Peter Cordes |
@bbaja42: note that GNU Coreutils wc does read the last block of the file, in case stat.st_size was only an approximation (like for Linux /proc and /sys files). I guess they decided not to make the main comment more complicated when they added that logic a couple lines down: lingrok.org/xref/coreutils/src/wc.c#246
|
|
| Dec 14, 2014 at 14:38 | comment | added | bbaja42 | I agree with notion of using "stat" over "wc" for filesize, however if you use "wc -c", no data will be read; instead lseek will be used to figure out the number of bytes in a file. lingrok.org/xref/coreutils/src/wc.c#228 | |
| Dec 9, 2013 at 19:18 | comment | added | Kevin Fegan | I would prefer using "stat" or "ls". Typically I don't like using "wc" to get file sizes because it physically reads the entire file. If you have a lot of files, or particularly large files, this can take a lot of time. But your solution is creative...+1. | |
| Apr 12, 2013 at 18:35 | review | Late answers | |||
| Apr 12, 2013 at 18:35 | |||||
| Apr 12, 2013 at 18:16 | history | answered | BZT | CC BY-SA 3.0 |