[cs631apue] blocks (-s) & size (-k -h)

sshah83 sshah83 at stevens.edu
Fri Oct 17 10:57:04 EDT 2014


Linux ls -s displays the number of blocks allocated to each file in unit 
of 1024 bytes or BLOCKSIZE environment variable (if it's set). for 
example

1) ls -s (if no BLOCKSIZE env variable is set)
  - file_blk_size  = (st_blocks*512)/1024.0


2) export BLOCKSIZE = 200
ls -s
  - file_blk_size = (st_blocks*512)/env_blksize

in both above cases if file_blk_size comes in decimal, you have to round 
that partial unit to next integer value.


Now if -k or -h is combined with ls -s, it does not use env BLOCKSIZE 
variable to calculate the number of blocks of
each file and modifies ls -s output. For example

export BLOCKSIZE = 200

ls -sk
- file_blk_size =  (st_blocks*512)/1024.0

even if the evn BLOCKSIZE is 200, it's ignored if -k is combined with ls 
-s.


On 10/17/2014 12:50 AM, xxu15 at stevens.edu wrote:
> 
> Hi,
> -k or -h is to show the file size, they override each other.
> 
> -s is to show the total number of blocks, which is a separate column.
> So, I DON'T UNDERSTAND, IN LS.PDF, WHAT'S THE MEANING OF "-K / -H
> MODIFIES THE -S OPTION".   
> 
> -------------------------
> 
> Sincerely,
> Xiang Xu (徐祥)
> Student ID: 10388813
> tel: +1 (201) 918-0570
>  +86 13851478402
> qq: 185904095
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue


More information about the cs631apue mailing list