Bash – ls show in megabytes can be set in bash script

bashlinuxls

To check the size in megabytes I have always to do –block-size=Mb. Can I set in bashrc so that when I do ls it should alway publish size in Mb?

Best Answer

Add the following line to your .bashrc file

alias ls="ls --block-size=M"

Then logout and log back in. ls should now have the desired flags.

You could find this information using man ls:

--block-size=SIZE
              scale sizes by SIZE  before  printing  them;  e.g.,
              '--block-size=M' prints sizes in units of 1,048,576
              bytes; see SIZE format below
Related Question