🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: it.comp.os.unix
Article #11

Re: Aiuto nel fare scipt

#11
From: Alessandro Selli
Date: Tue, 13 Mar 2007 13:28
51 lines
2959 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

never ha scritto:
> Ciao a tuttisono un po arruginito nell'awk ed avrei bisogno uno script
> che mi permetta di modificare una stringa in un file:
> esempio
> da
> /space/lna_docs/honyvem/2007Mar071249_1323/document.html
> a
> /space/lna_docs/honyvem/2007Mar071249_1323/

  Se la variabile AWK VAR contiene la stringa
"/space/lna_docs/honyvem/2007Mar071249_1323/document.html", puoi usare il
comando sub(/regexp/,"sub",targ), dove /regexp/ � l'espressione regolare
che individua la stringa da sostutuire, "sub" � la stringa che sostituir�
quella individuata dall'espressione regolare di prima e targ � l'oggetto
che deve essere mod�ficato.

  Un esempio pratico:

awk 'BEGIN {FILE = "/space/lna_docs/honyvem/2007Mar071249_1323/document.html"
VARIA = FILE
sub(/document\.html$/,"",VARIA)
print "Ho cambiato la stringa", FILE, "nella stringa", VARIA
}'

  Produce l'output:

Ho cambiato la stringa
/space/lna_docs/honyvem/2007Mar071249_1323/document.html nella stringa
/space/lna_docs/honyvem/2007Mar071249_1323/

> per poter verificare se tale directory esiste
> 
> Grazie mille
> never


- --
Alessandro Selli http://alessandro.route-add.net
AVVERTENZA: i messaggi inviati a "trappola" non mi arriveranno.
WARNING: messages sent to "trappola" will never reach me.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFF9qb43xmftOyIWosRApeRAJ9OoAR3jeHcwRQvDa0I3g5c0YlJZwCeI3Ls
suLpyv6iY1RkBAse6k8U0d4=
=U5O9
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <55nn60F25ro9kU1@mid.individual.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!out03a.usenetserver.com!news.usenetserver.com!in04.usenetserver.com!news.usenetserver.com!news.mailgate.org!erode.bofh.it!bofh.it!news.nic.it!robomod
References: <1173275834.099445.138340@p10g2000cwp.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939e,5dae5bd47be30333
X-Google-Attributes: gidf939e,public
X-Google-Language: ITALIAN,ASCII
From: Alessandro Selli <trappola@route-add.net>
Newsgroups: it.comp.os.unix
Subject: Re: Aiuto nel fare scipt
Date: Tue, 13 Mar 2007 14:28:24 +0100
Organization: Route-add.net
Message-ID: <55nn60F25ro9kU1@mid.individual.net>
References: <1173275834.099445.138340@p10g2000cwp.googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Orig-X-Trace: individual.net PH2+Dd82PSepI1fNK3wYSwsq0gETmxGIuHfBWPEkMC8ymH0taU
User-Agent: Mozilla Thunderbird 1.5.0.10 (X11/20070302)
In-Reply-To: <1173275834.099445.138340@p10g2000cwp.googlegroups.com>
X-Enigmail-Version: 0.94.2.0
Openpgp: url=http://alessandro.route-add.net/firma_pubblica_gpg.key
X-Originating-IP: 130.133.1.2
Approved: robomod@news.nic.it (1.22)
Sender: robomod@news.nic.it
X-Mail-Path: tok.cu.mi.it!outpost1.zedat.fu[UNTRUSTED]!relay1.zedat.fu[UNTRUSTED]!curry.zedat.fu[UNTRUSTED]!mod-submit@uni-berlin.de
Lines: 51
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!out03a.usenetserver.com!news.usenetserver.com!in04.usenetserver.com!news.usenetserver.com!news.mailgate.org!erode.bofh.it!bofh.it!news.nic.it!robomod