Re: Implementation of ls -l. How to calculate the number after total?
Jens Thoms Toerring wrote:
Tsvetelina Borisova <ts.borisova3@xxxxxxxxx> wrote:
Hello, I am writing a program in C that implements the UNIX command ls -l. I
understood that the number after total is the blocks that are given to the
files? I am completely sure because I couldn't find information about it.
Can someone help me and tell me what it is that number and how I can
calculated to show it in my implementation. Thanks in advance :)
[...]
If what you call 'total' is the length of the
file in bytes the following field is the date and time,
at least according to that standard. But keep in mind that
not all implementations of 'ls' may follow this standard.
I think what the OP wants is this part of the POSIX/SUS description of
ls (in the STDOUT section):
If any of the -l, -n, -s, -g, or -o options is specified, each
list of files within the directory shall be preceded by a status
line indicating the number of file system blocks occupied by files
in the directory in 512-byte units if the -k option is not
specified, or 1024-byte units if the -k option is specified,
rounded up to the next integral number of units, if necessary. In
the POSIX locale, the format shall be:
"total %u\n", <number of units in the directory>
--
Geoff Clare <netnews@xxxxxxxxxxxxx>
.
Relevant Pages
- FAQ 8.25 How can I capture STDERR from an external command?
... both STDOUT and STDERR will go the same place as the ... script's STDOUT and STDERR, unless the systemcommand redirects them. ... You can also use file-descriptor redirection to make STDERR a duplicate ... The first command sends both standard out and standard error to the ... (comp.lang.perl.misc) - FAQ 8.25 How can I capture STDERR from an external command?
... both STDOUT and STDERR will go the same place as the ... script's STDOUT and STDERR, unless the systemcommand redirects them. ... You can also use file-descriptor redirection to make STDERR a duplicate ... The first command sends both standard out and standard error to the ... (comp.lang.perl.misc) - FAQ 8.25 How can I capture STDERR from an external command?
... both STDOUT and STDERR will go the same place as the ... script's STDOUT and STDERR, unless the systemcommand redirects them. ... You can also use file-descriptor redirection to make STDERR a duplicate ... The first command sends both standard out and standard error to the ... (comp.lang.perl.misc) - FAQ 8.25 How can I capture STDERR from an external command?
... both STDOUT and STDERR will go the same place as the ... script's STDOUT and STDERR, unless the systemcommand redirects them. ... You can also use file-descriptor redirection to make STDERR a duplicate ... The first command sends both standard out and standard error to the ... (comp.lang.perl.misc) - FAQ 8.25 How can I capture STDERR from an external command?
... both STDOUT and STDERR will go the same place as the ... script's STDOUT and STDERR, unless the systemcommand redirects them. ... You can also use file-descriptor redirection to make STDERR a duplicate ... The first command sends both standard out and standard error to the ... (comp.lang.perl.misc) |
|