[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RES: [shell-script] Re: Deletar linhas
From: |
Julio Cezar Neves - DISB.O |
Subject: |
RES: [shell-script] Re: Deletar linhas |
Date: |
Wed, 28 Aug 2002 10:25:23 -0300 |
Luciano,
eu mandei uma sugestão e vc disse que não podia executá-la, já que o arquivo
não admitia comentários. Se vc souber a 1a. linha e a qtd de linhas a
deletar, proceda da forma abaixo. Esta executa que ksh ou bash.
Primeira=`grep -n "<padrao caracteristico da 1a linha>" <nome do arquivo> |
cut -f1 -d:`
Ultima=$((<qtd de linhas a deletar - 1> + Primeira))
sed "$Primeira,${Ultima}d" <nome do arquivo> > /tmp/$$
mv /tmp/$$ <nome do arquivo>
Prompt> cat bacalho.sh
Primeira=`grep -n "5555" testeq | cut -f1 -d:`
Ultima=$((3 + Primeira))
sed "$Primeira,${Ultima}d" testeq > /tmp/$$
mv /tmp/$$ testeq
Prompt> cat testeq
11111111111111111111111111
22222222222222222222222
333333333333333333333333
44444444444444444444
555555555555555555555
66666666666666666
7777777777777777777
8888888888888888888888888
9999999999999999
000000000000000000000
Prompt> bacalho.sh
Prompt> cat testeq
11111111111111111111111111
22222222222222222222222
333333333333333333333333
44444444444444444444
9999999999999999
000000000000000000000
[ ]s,
Julio Cezar Neves
-Eu Apoio o Software Livre-
-I Support Free Software-
* +55 21 2528-7070 / 9853-4044
*address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- RES: [shell-script] Re: Deletar linhas,
Julio Cezar Neves - DISB.O <=