[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ordering of args gives different results for du
From: |
Steve Ward |
Subject: |
ordering of args gives different results for du |
Date: |
Sun, 3 Jun 2007 21:54:17 -0400 |
I came across a quirk with 'du' when the order of some args are different.
Suppose there is a file named "foo.txt".
The following commands give different results:
du --bytes --human-readable foo.txt
du --human-readable --bytes foo.txt
Actual results:
The values displayed are different (one is the amount of bytes and the other
is the amount of bytes printed in a human readable format).
Expected results:
The values displayed are the same (should be the amount of bytes printed in
a human readable format)
Is it incorrect to expect that the two commands with the args in a different
order would give different results?
Here are the steps to reproduce...
####################
address@hidden ~]$ uname -a
Linux localhost.localdomain 2.6.21-1.3194.fc7 #1 SMP Wed May 23 22:35:01 EDT
2007 i686 athlon i386 GNU/Linux
address@hidden ~]$ du --version
du (GNU coreutils) 6.9
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
Written by Torbjorn Granlund, David MacKenzie, Paul Eggert, and Jim
Meyering.
address@hidden ~]$ du --bytes foo.txt
2215936 foo.txt
address@hidden ~]$ du --human-readable foo.txt
2.2M foo.txt
address@hidden ~]$ du --bytes --human-readable foo.txt
2.2M foo.txt
address@hidden ~]$ du --human-readable --bytes foo.txt
2215936 foo.txt
####################
Looking at the source code in du.c:
//-------------------
case 'b':
apparent_size = true;
human_output_opts = 0;
output_block_size = 1;
break;
/* <snip> */
case 'h':
human_output_opts = human_autoscale | human_SI | human_base_1024;
output_block_size = 1;
break;
//-------------------
Why does "--bytes" turn off "--human-readable"?
Why does "--human-readable" turn on "--block-size=1"?
Steve Ward
- ordering of args gives different results for du,
Steve Ward <=