filesize

Table of Contents

Prototype: filesize(filename)

Return type: int

Description: Returns the size of the file filename in bytes.

If the file object does not exist, the function call fails and the variable does not expand.

Arguments:

  • filename: string - File object name - in the range: "?(/.*)

Example:

Run:

body common control
{
      bundlesequence => { example };
}

bundle agent example
{
  vars:
      # my own size!
      "exists" int => filesize("$(this.promise_filename)");
      "nexists" int => filesize("/etc/passwdx");

  reports:
      "File size $(exists)";
      "Does not exist: $(nexists)";
}

Output:

R: File size 301
R: Does not exist: $(nexists)

History: Was introduced in version 3.1.3, Nova 2.0.2 (2010).