bug-coreutils
[Top][All Lists]
Advanced

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

Re: programs


From: Juhapekka Tolvanen
Subject: Re: programs
Date: Fri, 8 Jan 2010 06:58:58 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

On Fri, 08 Jan 2010, +06:42:05 EET (UTC +0200),
Matthew Woehlke <address@hidden> pressed some keys:

> Juhapekka Tolvanen wrote:
> >On Thu, 31 Dec 2009, +14:51:44 EET (UTC +0200),
> >Eric Blake pressed some keys:
> >
> >>According to Juhapekka Tolvanen on 12/30/2009 4:35 PM:
> >>>I wanted to do this: Give sizes of each files and directories located
> >>>in $PWD in human-readable-format AND sort output according to sizes of
> >>>those files and directories.
> >>
> >>What's wrong with:
> >>
> >>du -sh0 * | sort -hz | tr '\0' '\n'
> >>
> >>besides needing coreutils 7.5 or newer?
> >
> >What if size of one directory is rounded UP to 1M and size of other
> >directory is rounded DOWN to 1M? How sort-command can know know, which
> >one is bigger? I am sure, that sorting must be done according to size
> >in bytes, not according to size of human-readable units.
> 
> Okay. What is wrong with:
> 
> du -B 1 -s -0 * \
>   | sort -nz \
>   | awk -v RS='\0' '{print $2}' \
>   | xargs -d '\0' du -sh
> 
> ?

It does not work for me:

% ls
000misc/                  Front242/            Ministry/
VNV_Nation/
Aavikko/                  Frontline_Assembly/  Nitzer_Ebb/
Wendy_Carlos/
Apoptygma_Berzerk/        Kemopetrol/          Organ/            YMO/
Art_of_Noise/             KMFDM/               Rammstein/
Coil/                     Kraftwerk/           Revolting_Cocks/
Einstuerzende_Neubauten/  Laibach/             Type_O_Negative/

% du -B 1 -s -0 * | sort -nz | awk -v RS='\0' '{print $2}' | xargs -d
'\0' du -sh
du: tiedostoa
”Coil\nLaibach\nWendy_Carlos\nAavikko\nRevolting_Cocks\nFrontline_Assembly\nNitzer_Ebb\nArt_of_Noise\nEinstuerzende_Neubauten\nFront242\nKemopetrol\nKMFDM\nVNV_Nation\nRammstein\nType_O_Negative\nMinistry\nApoptygma_Berzerk\nOrgan\nYMO\n000misc\nKraftwerk\n”
ei voi käsitellä: Tiedostoa tai hakemistoa ei ole
[1]    21748 done       du -B 1 -s -0 * | 
       21749 done       sort -nz | 
       21750 done       awk -v RS='\0' '{print $2}' | 
       21751 exit 123   xargs -d '\0' du -sh

It says ”du: A file (very long text) can not be handled: File or
directory do not exist.”

% whence -savc awk
/usr/bin/awk -> /usr/bin/gawk
/opt/heirloom/5bin/posix2001/awk -> /opt/heirloom/5bin/posix2001/nawk
/opt/heirloom/5bin/awk -> /opt/heirloom/5bin/oawk
/opt/heirloom/5bin/posix/awk -> /opt/heirloom/5bin/posix/nawk
/opt/heirloom/5bin/s42/awk -> /opt/heirloom/5bin/posix/nawk
/opt/plan9/bin/awk


Anyway, this WorksForMe™:

http://iki.fi/juhtolv/hacks/sh/sortdu.sh.bz2

> Incidentally, instead of re-executing 'du' via xargs, I do this:
> 
> awk -v RS='\0' '{
>   if ( $1 > 0x3F000000 )
>     printf "%6.1fG\t", $1 / 0x40000000 ;
>   else if ( $1 > 0xF0000 )
>     printf "%6.1fM\t", $1 / 0x100000 ;
>   else if ( $1 > 0x300 )
>     printf "%6.1fK\t", $1 / 0x400 ;
>   else
>     printf "%6i\t", $1 ;
>   $1="" ;
>   print $0 ;
> }'

How that awk-snippet is actually used? Can you provide it as a
shell-script-file?



-- 
Juhapekka "naula" Tolvanen * http colon slash slash iki dot fi slash juhtolv
"Quidquid Latine dictum sit altum videtur."




reply via email to

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