Article View: es.comp.os.linux.programacion
Article #13577[awk] Mostrar profundidad de un directorio
From: Manuel López Moreno
Date: Thu, 08 Feb 2001 17:46
Date: Thu, 08 Feb 2001 17:46
63 lines
2488 bytes
2488 bytes
Historia: Me he cargado 2 CDs al querer grabar "on-the-fly" un
directorio de mirror:
# nice --20 mkisofs [bla-bla] | nice --20 cdrecord
Sospecho que el problema era (entre otros) el excesivo nivel de
profundidad del �rbol de directorios. Esto hace que mkisofs tenga
que trabajar m�s de la cuenta.
Para que no me vuelva a pasar (adem�s de escribir la imagen en
disco):
---------- [tree-level.awk] ------------------------------------------
#! /bin/awk -f
BEGIN {
FS = "/"
maxlevel = 0
}
{
l = NF-1
level[l]++
if (l > maxlevel)
maxlevel = l
}
END {
for (x = 1; x <= maxlevel; x++)
{
y = level[x]
printf "%d\t%d\t", x, y
for (i = 0; i < log(y)*2; i++)
printf "%c", "+"
printf "\n"
}
}
----------------------------------------------------------------------
$ cd /directorio/listo/para/grabar
$ find | tree-level.awk
1 4 +++
2 22 +++++++
3 833 ++++++++++++++
4 6952 ++++++++++++++++++
5 10537 +++++++++++++++++++
6 13741 ++++++++++++++++++++
7 8346 +++++++++++++++++++
8 7238 ++++++++++++++++++
9 1431 +++++++++++++++
10 345 ++++++++++++
11 18 ++++++
Por cierto, �existe alguna utilidad unix (directa, no script),
para repetir un car�cter n veces, tal que:
$ repetir 20 "?"
????????????????????
--
Manuel L�pez Moreno PGP key ID: 0xC6C9455E
---
Visita: Web de es.comp.os.linux.* <http://www.escomposlinux.org>
Technical Details
Message-ID:
<slrn985b3m.19s.luname@mantium.luname.net>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!howland.erols.net!portc.blue.aol.com.MISMATCH!portc01.blue.aol.com!newsfeed.skycache.com!Cidera!newsfeed.comtenidos.com!m2newsfeed.uni2.es!m2newsread.uni2.es.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,3aa5360989500bfc,start X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2001-02-08 09:46:23 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!howland.erols.net!portc.blue.aol.com.MISMATCH!portc01.blue.aol.com!newsfeed.skycache.com!Cidera!newsfeed.comtenidos.com!m2newsfeed.uni2.es!m2newsread.uni2.es.POSTED!not-for-mail From: luname@linuxfan.com (Manuel López Moreno) Newsgroups: es.comp.os.linux.programacion Subject: [awk] Mostrar profundidad de un directorio Message-ID: <slrn985b3m.19s.luname@mantium.luname.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit User-Agent: slrn/0.9.6.2 (Linux) Lines: 63 Date: Thu, 08 Feb 2001 17:46:03 GMT NNTP-Posting-Host: 62.37.174.78 X-Complaints-To: abuse@wanadoo.es X-Trace: m2newsread.uni2.es 981654363 62.37.174.78 (Thu, 08 Feb 2001 18:46:03 MET) NNTP-Posting-Date: Thu, 08 Feb 2001 18:46:03 MET Organization: Servidor Usenet News de Uni2/Wanadoo