Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm tired of using aliases or typing -h. I want human readable output 24/7. Is there a way to enable it all the time for all commands that offer it?

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

From a search through the man pages, on a Linux system, I find that the command supporting a --human-readable option are the following: df dir du ls rsync vdir. This search is obviously limited to installed packages on this particular machine.

For each of them you can define an alias in ~/.bashrc if you use bash as a login shell (or a function, if you prefer), like the following:

alias df='df --human-readable'

Ok, I read you would not use aliases, but once set in .bashrc you can forget about them, so I cannot understand your request.

It does not seem that these applications support setting parameters through environment variables.

share|improve this answer
    
Yeah, I guess aliases are the best I can do. Thanks. –  Humm Sep 4 '11 at 14:35
    
The only alternative I see, would be to modify the source, and compile it yourself, which would make you responsible for proper updates, containing this default again and again - surely using an alias is more easy and less error prone. –  user unknown Sep 4 '11 at 17:39
2  
You can play with the BLOCKSIZE environment variable. It isn't exactly the same as human readable, but can make all commands that output blocks(like ls, du, etc) use the same size(like export BLOCKSIZE=M) which can make them easier to read. –  polynomial Sep 5 '11 at 4:29
    
@polynomial: +1, but it seems that ls do not respect BLOCKSIZE. By the way, where is documented such a variable? –  enzotib Sep 5 '11 at 8:08
    
The various man pages mention it in their 'environment variables' section. ls respects it, you have to use -s to have it print sizes. –  polynomial Sep 5 '11 at 21:29
show 1 more comment

For GNU coreutils, including ls, df, and du, you can set the BLOCK_SIZE environment variable.

$ export BLOCK_SIZE=human-readable
$ ls -l 4-megabyte-file 
-rw-r--r-- 1 mikel mikel 4.0M Dec 10 08:09 4-megabyte-file
$ du 4-megabyte-file 
4.0M    4-megabyte-file
$ df .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       110G   16G   89G  15% /

BLOCK_SIZE documentation

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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