From APUE:

The du command on many BSD-derived systems reports the number of 1,024-byte blocks. Solaris reports the number of 512-byte blocks. On Linux, the units reported depend on the whether the POSIXLY_CORRECT environment is set. When it is set, the du command reports 1,024-byte block units; when it is not set, the command reports 512-byte block units.

First I run:

ls -ls APUE.pdf
du -s APUE.pdf


18680 -rw-r--r-- 1 tianhe tianhe 19126025 2月 25 17:09 APUE.pdf
18680 APUE.pdf

Which is 19126025 / 18680 = 1023.877141328. So it's reporting as 1024-byte blocks.

Then I type: POSIXLY_CORRECT=1 in the current shell and run the above command again but still get the same.

What's wrong here?

  • a bit of info is missing here, have you tried adding it as an export in the .bashrc and then sourcing the .bashrc instead? – tatsu Feb 27 at 10:19
  • @tatsu no. Isn't POSIXLY_CORRECT=1 would be enough for the current shell? – Rick Feb 27 at 10:32
  • yeah it should but doubting things will always work as intended usually allows you to uncover solutions you normally wouldn't ;) btw had you found this? stackoverflow.com/questions/38605463/… – tatsu Feb 27 at 10:33
  • env POSIXLY_CORRECT=1 ? – tatsu Feb 27 at 10:36
  • 1
    @tatsu Danm it works *_! – Rick Feb 27 at 10:41

You should be typing :




this is the correct syntaxe.

hope this helps :)

  • But I wonder why POSIXLY_CORRECT=1 doesn't work, I can't get POSIXLY_CORRECT value by printenv | grep POSIXLY_CORRECT. – Rick Feb 27 at 10:46
  • I think this guy pretty much answers that : stackoverflow.com/a/38605674/4770754 – tatsu Feb 27 at 10:47
  • No. I think it's not talking about the same thing. I just tried export POSIXLY_CORRECT=1 and it works(printenv has POSIXLY_CORRECT). So by doing POSIXLY_CORRECT=1, it did not write the variable. – Rick Feb 27 at 10:51
  • yeah I don't know if this is more or less recent but that seems to be the new syntax. I generally type export because it works. I experiment – tatsu Feb 27 at 10:53
  • Ya, thank you anyway. I would go search difference between adding export and not. – Rick Feb 27 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.