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

xxu15 at stevens.edu xxu15 at stevens.edu
Fri Oct 17 11:31:40 EDT 2014


Hi,

My confusion is:
In the pdf, it is said -k(-h) modifies -s.
But, -k(-h) is used to show the "st_size column", while -s is used to show the "st_blocks  column". So -k(-h) does not modifies -s, which is in conflict with what the ls.pdf said.




Sincerely,
Xiang Xu (徐祥) 
Student ID: 10388813
tel: +1 (201) 918-0570
      +86 13851478402
qq: 185904095

From: sshah83
Date: 2014-10-17 10:57
To: cs631apue
Subject: Re: [cs631apue] blocks (-s) & size (-k -h)
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
_______________________________________________
cs631apue mailing list
cs631apue at lists.stevens.edu
https://lists.stevens.edu/mailman/listinfo/cs631apue
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20141017/5616e7c2/attachment.html>


More information about the cs631apue mailing list