The default unit of `du` command, why is it implicit?

Code:
# du
123456
This result should be in byte by default, but it is in kilobyte in fact. This is not complete.
BTW, the document doesn't mention the default unit of the result in this case.
 
I guess this is in KB because of this line in your ~/.cshrc

Code:
setenv  BLOCKSIZE       K

Change it to M to get the size in Megabytes or G for Gigabytes.

Please see man environ | less -p BLOCKSIZE for more information.
 
bkouhi said:
I guess this is in KB because of this line in your ~/.cshrc

Code:
setenv  BLOCKSIZE       K

Change it to M to get the size in Megabytes or G for Gigabytes.

Please see man environ | less -p BLOCKSIZE for more information.

It is a little complex, if a unit is added in the result, it is completed by itself.
 
jronald said:
It is a little complex, if a unit is added in the result, it is completed by itself.

That's why there is a -h option to several commands that use BLOCKSIZE. The idea of having commands outputting numbers is useful when you have to elaborate such results in scripts and do not have to deal with alpha-numerical strings.
 
I like it, too. But wouldn't it be nice if sort had a -h switch to accept that output format for sorting input? E.g. du -hcs * | sort -h

I know, if I wasn't being lazy I would just do it myself.
 
Uniballer said:
I like it, too. But wouldn't it be nice if sort had a -h switch to accept that output format for sorting input? E.g. du -hcs * | sort -h

I'm not sure that adding extra switches to other commands is the right solution. I mean, the -h flag is used when the next element in the pipe is the human, not another program.
So I see more the usage of a small awk(1) script or the usage of units(1) or stuff like that to solve the problem you mention.
 
fluca1978 said:
That's why there is a -h option to several commands that use BLOCKSIZE. The idea of having commands outputting numbers is useful when you have to elaborate such results in scripts and do not have to deal with alpha-numerical strings.

If it is going to support script, additional options could be there.
By default it should be self-explained.
 
Back
Top