Groups | Search | Server Info | Login | Register


Groups > alt.comp.lang.shell.unix.bourne-bash > #235

tr squeeze repeats does not remove multiple spaces coming from a piped du command

Path csiph.com!aioe.org!.POSTED!not-for-mail
From "Zangune" <Zangune@Example.Com>
Newsgroups alt.comp.lang.shell.unix.bourne-bash
Subject tr squeeze repeats does not remove multiple spaces coming from a piped du command
Date Wed, 3 Oct 2018 17:05:43 +0200
Organization Aioe.org NNTP Server
Lines 31
Message-ID <pp2ltd$1908$1@gioia.aioe.org> (permalink)
Reply-To "Zangune" <Zangune@Users.SourceForge.Net>
NNTP-Posting-Host sTtZ1UIg/NXk8aO3UtBd6Q.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; format=flowed; charset="Windows-1252"; reply-type=original
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.7246
X-MSMail-Priority Normal
X-Priority 3
X-Newsreader Microsoft Outlook Express 6.00.2900.5931
X-Notice Filtered by postfilter v. 0.8.3
Xref csiph.com alt.comp.lang.shell.unix.bourne-bash:235

Show key headers only | View raw


Greetings, I want to know the total size of a directory content, so I 
use this command:

du -c /path | tr -s ' '

but I got this (this is just the last line):

510    total

please note that there are 4 spaces between "0" and "t".
I would expect the result to be:

510 total

please note that there is just one space between "0" and "t".
As far as I can see, the "du" command result is alined in columns with 
spaces, but the "tr" command does not remove those repeated spaces like 
it does in

echo 'a       b' | tr -s ' '

Why doesn't a "tr" command with the "squeeze repeats" option remove 
repeated spaces of a piped "du" command result?
Please note that I found a workaround, this one:

echo $(du -c /path)

but I am more interested in the theoretical problem solution (and 
logic), rather than the practical one.
Regards. 

Back to alt.comp.lang.shell.unix.bourne-bash | Previous | NextNext in thread | Find similar


Thread

tr squeeze repeats does not remove multiple spaces coming from a piped du command "Zangune" <Zangune@Example.Com> - 2018-10-03 17:05 +0200
  Re: tr squeeze repeats does not remove multiple spaces coming from a piped du command "Michael F. Stemper" <michael.stemper@gmail.com> - 2018-10-03 12:47 -0500
    Re: tr squeeze repeats does not remove multiple spaces coming from a piped du command "Zangune" <Zangune@Example.Com> - 2018-10-04 01:44 +0200
  Re: tr squeeze repeats does not remove multiple spaces coming from a piped du command Grant Taylor <gtaylor@tnetconsulting.net> - 2018-10-03 11:49 -0600
    Re: tr squeeze repeats does not remove multiple spaces coming from a piped du command "Zangune" <Zangune@Example.Com> - 2018-10-04 01:54 +0200
      Re: tr squeeze repeats does not remove multiple spaces coming from a piped du command Grant Taylor <gtaylor@tnetconsulting.net> - 2018-10-03 22:48 -0600

csiph-web