Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 12
    @haunted85 stat is the most straightforward way, assuming you're using Linux or Cygwin (stat isn't standard). wc -c as suggested by Eugéne is portable. Commented Jul 14, 2011 at 10:02
  • 10
    stat: illegal option -- c Commented Apr 27, 2017 at 13:42
  • stat --printf="%s" file.txt doesn't output anything on Debian Jessie... Commented Apr 29, 2017 at 20:36
  • 21
    On MacOS this works: stat -f%z myfile.tar Commented May 6, 2018 at 10:40
  • 2
    @woohoo Your prompt overwrites the output. man stat says that --printf omits the trailing newline. Use --format or -c to see the output. Gain more insight by comparing stat --printf="%s" file.any | xxd - to stat -c "%s" file.any | xxd - Commented Jun 18, 2019 at 11:06