coreutils
[Top][All Lists]
Advanced

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

Re: Numfmt tool – Applying space and comma to output's sizes


From: Bernhard Voelker
Subject: Re: Numfmt tool – Applying space and comma to output's sizes
Date: Fri, 23 Nov 2018 01:00:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0

On 11/22/18 2:57 PM, Ricky Tigg wrote:
> Component on Fedora: coreutils.x86_64 8.30-6.fc29
> 
> Hi. with a new purpose to observe a consign
> <https://mywiki.wooledge.org/ParsingLs> which is to avoid parsing outputs
> of function ls(1) and doubting the object of the present may be eligible
> for an issue report I expose it first here.
> 
> I got a command ' numfmt --to=iec-i --
> suffix=B --format "%.2f"'working as expected:
> 
> Model of current size output: 1,35KiB (<value><dot><value><unit>).
> Model of size output I attempt to achieved: 1,35 KiB
> (<value><comma><value><space><unit>).
> 
> $ for i in *; do printf "%s %s\n" $(stat -c %s "$i" | numfmt --to=iec-i --
> suffix=B --format "%.2f") "$i"; done
> 
> Modifying it such as ' numfmt --to=iec-i --suffix=B --format " %,2f"' does
> not work any more.
> 
> I attempt to apply it in that model of command:
> $ for i in *; do printf "%s %s\n" $(stat -c %s "$i" | numfmt --to=iec-i
> --suffix=B --format "%.2f") "$i"; done
> 
> Is there possibly any work-around related to numfmt? Any suggestion is
> welcome. Regards R.T.

The use of comma instead of dot depends on the collation in the locale,
e.g. 'de_DE.UTF-8' has it.
Re. a blank between the number value and the unit: why not use e.g. sed
to post-process?

  $ stat -c '%s %n' * \
      | LC_ALL=de_DE.UTF-8 numfmt --to=iec-i --suffix=B --format "%.2f" \
      | sed 's/\([0-9,]*\)\(.*B\)/\1 \2/'
  10,52 KiB a-ten-K-file
  4,00 KiB dir
  0,00 B empty

Is this what you wanted to achieve?

Have a nice day,
Berny



reply via email to

[Prev in Thread] Current Thread [Next in Thread]