eliminare numeri di riga da un file con sed in bash

ho un file fatto in questo modo
numero testo
esempio

4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

ho bisogno di eliminare solo i numeri di riga ottenendo così un file pronto all’uso.
il comando è


sed -i "s/^[0-9]*//g" nomefile

-i[SUFFISSO] o –in-place[=SUFFISSO] « richiede di modificare direttamente il file.

esaminiamo
“s/^[0-9]*//g”

/^[0-9]*/ trova tutti i numeri presenti a inizio riga
// li sostituisce con una carattere nullo

per i caratteri s e g guardare
http://www.gentoo.org/doc/it/articles/l-sed2.xml

Per ulteriori info
http://natonelbronx.wordpress.com/2007/12/02/sed-programma-per-manipolare-e-filtrare-flussi-di-testi/

Lascia un Commento