10.3.25 getFileSize (gets size of file)
Syntax
getFileSize [-k|-m] path-name
Description
This command outputs the size of the file specified for argument.
Arguments
- -k
-
This command outputs the size in kilobytes (1 kilobyte = 1024 bytes).
- -m
-
This command outputs the size in megabytes (1 megabyte = 1048576 bytes).
If you do not specify any of the aforementioned options, the size is output in units of bytes. If both of the aforementioned options are specified, the command finishes with an error.
This command outputs the size by truncating at the decimal point.
- path-name
-
This command specifies the path name of the file from which size is obtained.
Output to the standard output
Character string indicating the size of file.
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
Not less than 1 |
Termination with an error |
Notes
In Windows, 0 is always output for the size of the directory.
In UNIX, 0 is always output for the size of device file.
Examples
getFileSize log.txt # "1279571" is output. getFileSize -k log.txt # "1250" is output. getFileSize -m log.txt # "2" is output.