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

Modifica file di testo con sed, replace o grep...?



Salve a tutti,
avrei bisogno di modificare via script un file di testo che contiene un vhost settato in apache, la loro struttura è questa:

#sitotest.it
        <VirtualHost *>
                DocumentRoot    /home/fabio/www/sitotest
                ServerName      server1.sitotest.it
                ServerAlias     server4.sitotestalias.it

                ServerAdmin     fabio.mm@gmail.com

                CustomLog /home/fabio/log/sitotest-access.log combined
                ErrorLog /home/fabio/log/sitotest-error.log
                LogLevel warn
        </VirtualHost>

quello che mi serve è commentare le linee ServerName e ServerAlias, poi aggiungere una nuova linea ServerName con un nome di tezo livello differente.

Un esempio chiarirà:
sostituire server1.sitotest.it con > mirror2.sitotest.it

#sitotest.it
        <VirtualHost *>
                DocumentRoot    /home/fabio/www/sitotest
#                ServerName      server1.sitotest.it
#                ServerAlias     server4.sitotestalias.it
                ServerName      mirror2.sitotest.it

                ServerAdmin     fabio.mm@gmail.com

                CustomLog /home/fabio/log/sitotest-access.log combined
                ErrorLog /home/fabio/log/sitotest-error.log
                LogLevel warn
        </VirtualHost>

Ho fatto il commento della linea con sed ( sed '/ServerName/ s/^/#/' sitotest.txt ), ma ora dovrei fare il replace, e non ho idea di come

Chi può aiutarmi?

grazie,
fabio


--
--
<Fabio Mora>
Cel.: 340-1504097 - eMail: fabio.mm@gmail.com
-
Libera il pianeta! Usa Linux!
http://www.gallug.it - http://www.ubuntu-it.org/

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: