[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Ajuda no shell
From: |
Eduardo Otubo |
Subject: |
Re: [shell-script] Ajuda no shell |
Date: |
Tue, 15 May 2007 22:01:29 -0300 |
André,
Uma resolução quick & dirty, mais conhecida como gambearra:
otubo@lisa ~ $ cat divide.sh
#/bin/bash
arquivo="teste1.txt";
arquivo_entrada="teste.txt";
for line in $(cat $arquivo_entrada); do
echo $line >> $arquivo;
if [[ $line == "teste" ]]; then
arquivo="teste2.txt";
fi
done
otubo@lisa ~ $ cat teste.txt
1
2
3
4
5
teste
6
7
8
9
teste
otubo@lisa ~ $ cat teste1.txt
1
2
3
4
5
teste
otubo@lisa ~ $ cat teste2.txt
6
7
8
9
teste
Certamente há uma resolução bem melhor pra esse problema. Mas por hora
pensei apenas nisso :-)
[]'s
On 5/15/07, André Unno <address@hidden> wrote:
Bom dia pessoal.
Eu tenho um arquivo texto com o seguinte conteúdo:
1
2
3
4
5
teste
6
7
8
9
teste
Eu preciso dividir esse arquivo em dois onde o primeiro arquivo deve conter:
1
2
3
4
5
teste
E o segundo arquivo deve conter:
6
7
8
9
teste
Alguém poderia me ajudar?
--
André Unno
GNU/LinuxCounter#390708
http://counter.li.org
O sistema pediu: "Requires Windows 9x, Windows 2000 or better".
Então eu instalei Linux.
[As partes desta mensagem que não continham texto foram removidas]
--
Eduardo Otubo
Linux Registered User #424252
http://z3r00.blogspot.com/
|_|0|_|
|_|_|0|
|0|0|0|