Groups | Search | Server Info | Login | Register


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

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

From "Michael F. Stemper" <michael.stemper@gmail.com>
Newsgroups alt.comp.lang.shell.unix.bourne-bash
Subject Re: tr squeeze repeats does not remove multiple spaces coming from a piped du command
Date 2018-10-03 12:47 -0500
Organization A noiseless patient Spider
Message-ID <pp2vbl$a30$1@dont-email.me> (permalink)
References <pp2ltd$1908$1@gioia.aioe.org>

Show all headers | View raw


On 2018-10-03 10:05, Zangune wrote:
> 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".

Are you quite sure? I just tried the same thing, and didn't find any
spaces between the number and the word "total". What I did find was
a tab:

username@hostname$ du -c dtd
84	dtd
84	total
username@hostname$ du -c dtd | sed 's/ /s/g'
84	dtd
84	total
username@hostname$ du -c dtd | sed 's/\t/tab/g'
84tabdtd
84tabtotal
username@hostname$

> 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,

Nope, tabs are much better for column alignment than are spaces. They
yield, one might say, a "tabular" format.

-- 
Michael F. Stemper
Psalm 94:3-6

Back to alt.comp.lang.shell.unix.bourne-bash | Previous | NextPrevious in thread | Next 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