Re: [PATCH 0/4] fincore command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, thank you for comments.

On Mon, 13 Mar 2017 15:50:41 +0100, Karel Zak <kzak@xxxxxxxxxx> wrote:
> Not sure if I like the format ;-)
> 
>  $ fincore /etc/fstab /bin/emacs
>  1          1544       /etc/fstab
>  4156       17163144   /bin/emacs
> 
> Why we need file size there? Would be better to use filename as the
> first column?

* Why we need file size there?

I don't insist including the file size column.

The original reason was that I assumed that a user may want to know
how much part of the file printed by fincore is in core. The file-size
column is for the hint.

How about adding an option to control show the column (--file-size|-s)?
Or should I delete the column fron the output completely?

* Would be better to use filename as the first column?

I follow the format that du and ls commands use:

    $ du /etc/passwd
    4	/etc/passwd

    $ ls -i /tmp | head
    67003 emacs1000
    47611 systemd-private-dd34e7d700c6441db79e4caa7b3c3205-colord.service-N7dhub
    24891 systemd-private-dd34e7d700c6441db79e4caa7b3c3205-rtkit-daemon.service-WbOmt1

du and ls are popular enough. So potential users of fincore
command may be familiar with the formats.

There are two benefits this(du style) format.

+ awk/read/cut commands friendly

White spaces can be included in a file name.
As the result, a user cannot assume the column
for the page counts easily if filename is at the
first column.

e.g. 

    (the format in my patch)
    $ touch 'a b'
    $ ./util-linux/fincore 'a b'
    0          0          a b
    $ ./util-linux/fincore 'a b' | awk '{print $1}'
    0
    $ ./util-linux/fincore 'a b' | { read A REST; echo $A; }
    0
    $ ./util-linux/fincore 'a b' | cut -d ' ' -f1 
    0

+ beauty of output

If filename is at the first column, I wonder
how can I print lines in column aligned way:

    0         -1         /foo/bar/baz/very---long---file---name
    0          0          shortname

By finding the longest file name from arguments passed to fincore
command, the column length can be calumniated, and fincore may be
able to print following lines:

    /foo/bar/baz/very---long---file---name	0         -1         
    shortname					0          0

However, I wonder what I should do if multibyte characters are
used in the file name.

Of course, the column alignment is less important than providing the
way to know much file contents are incore to users.

> it would be also nice have a way how to print only the number if only one
> file specified. Then you can use it in scripts without awk (or so),
> just:
> 
>   FILEPAGES=$(fincore /bin/emacs)
> 

In the station(interactive use) that a user of fincore knows the
number of file names passed to the command, printing only the number
is bettern. However, there can be a situation(scripting) that a user
cannot know the number of file names.

{ 
  FILES=...
  FILES="$FILES $tmp"
  ...
  
  fincore $FILES
} | do_something

In such case the columns are fixed(the page numbers and file name)
will be better for people writing `do_something'. For the such
use case, I would like to add an option --print-filename-always.
The default behavior (behavior without the option) should be
implemented as what you wrote (just printing the number).
Is it o.k.?

After getting feedback from you, I will submit v2 patches.

Masatake YAMATO
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux