My answer uses wc which requires read permissions for the files. Normally to obtain a file's byte size, like with a stat command, you don't require read permissions but only execute/search permissions to ancestor directories. See also Stéphane Chazelas's helpful comments below. On macOS you can use BSD stat -f %z to obtain a file's byte size, and on systems using the GNU coreutils toolset, you can use GNU stat -c %s. If you have zsh you can use zstat with zmodload -F zsh/stat b:zstat; zstat -H struct_stat_hash <your-file>; echo "${struct_stat_hash[size]}" to get a file byte size, without needing read permissions.
"zmodload -F zsh/stat b:zstat" seems to be an ancient relic from zsh v4.3.5, but is still kept in the docs
Aeronautix
- 153
- 1
- 7
Re-read my answer, replace headscratcher wc-terminal-output info with wc-no-filename-output info
Aeronautix
- 153
- 1
- 7