You are not logged in.

#1 2012-05-31 07:01:11

rnarch
Member
Registered: 2012-03-17
Posts: 292

Command 'ls -lk' not showing in kilobytes

On my system I have this peculiar problem. The command 'ls -lk' does not show in kilobytes, rather in bytes:

[abcd@myhost dropbox]$ ls -lk
total 44580
-rw-r--r-- 1 cardio users 27846860 May 31 12:15 dropbox-1.4.7-1-i686.pkg.tar.xz
-rw-r--r-- 1 cardio users      288 Sep  5  2011 dropbox.desktop
-rw-r--r-- 1 cardio users 17765299 May 31 12:14 dropbox-lnx.x86-1.4.7.tar.gz
-rw-r--r-- 1 cardio users     9896 May 29  2011 dropbox.png
-rw-r--r-- 1 cardio users     1597 May 25 15:46 PKGBUILD
-rw-r--r-- 1 cardio users    12278 Sep  5  2011 terms.txt
[abcd@myhost dropbox]$

I checked aliases. It only shows following:

[abcd@myhost dropbox]$ alias
alias ls='ls --color=auto'
[abcd@myhost dropbox]$

I could not find posts on this in forums, wiki or google. The man page says -k option should show in kilobytes. Thanks for your help.

Offline

#2 2012-05-31 07:04:20

bohoomil
Banned
Registered: 2010-09-04
Posts: 2,377
Website

Re: Command 'ls -lk' not showing in kilobytes

Run

ls -lh

Eidt: the '-k' option refers to the block size:

-k, --kibibytes
              use 1024-byte blocks

Last edited by bohoomil (2012-05-31 07:05:11)


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#3 2012-05-31 07:56:44

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: Command 'ls -lk' not showing in kilobytes

Command 'ls -lh' works well but why the -k option does not work?

Offline

#4 2012-05-31 08:28:30

bohoomil
Banned
Registered: 2010-09-04
Posts: 2,377
Website

Re: Command 'ls -lk' not showing in kilobytes

'-k' option works, but not in the way you expect it to. It refers to the way ls computes size values. I'm just wondering if what you want is simply a thousand separator, e.g.:

-rw-r--r-- 1 bohoomil users 1,672,702 May 26 22:10 article.pdf

If so, you have to do something different: create an alias to ls in your .bashrc, like this:

alias ls="BLOCK_SIZE=\'1 ls -F --color=auto"

After you restart your terminal, run 'ls -lh' as suggested above and see if you get what you want.


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#5 2012-05-31 08:44:17

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Command 'ls -lk' not showing in kilobytes

The man page is kinda sparse, so here's some additional detail from the info page:

`-k'
`--kibibytes'
     Set the default block size to its normal value of 1024 bytes,
     overriding any contrary specification in environment variables
     (*note Block size::).  This option is in turn overridden by the
     `--block-size', `-h' or `--human-readable', and `--si' options.

     The `-k' or `--kibibytes' option affects the per-directory block
     count written by the `-l' and similar options, and the size
     written by the `-s' or `--size' option.  It does not affect the
     file size written by `-l'.

Offline

#6 2012-05-31 12:19:24

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: Command 'ls -lk' not showing in kilobytes

I had used this command earlier and I tried again the command 'ls -lk' in other (U...know..which) distro and it works as expected (eg 4 instead of 4125 is shown).

But this is hardly a problem. I have now got used to typing 'ls -lh' .

I really like the tip about the thousand separator. Thanks.

Last edited by rnarch (2012-05-31 12:25:43)

Offline

Board footer

Powered by FluxBB