![]() |
Olá e boas-vindas de Estados Unidos para o UNIX e Linux Forum! Obrigado por visitar e fazer parte da nossa comunidade global.
|
|
google unix.com
|
|||||||
| Fóruns | Registar | Fórum Regimento | Ligações | Álbuns | FAQ | Lista deputados | Calendário | Pesquisa | Today's Posts | Mark Forums Read |
| Programação Shell Script e Post perguntas sobre ksh, CSH, SH, BASH, Perl, PHP, SED, Awk e outros scripts shell e shell scripts línguas aqui. |
Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
|
||||
| Fio | Thread Starter | Fórum | Respostas | Última postagem |
| Combinando dois arquivos | hemangjani | Programação Shell Script e | 7 | 06-13-2007 11:32 |
| Combinando dois arquivos | stevefox | Programação Shell Script e | 4 | 02-20-2006 05:09 |
| Combinando dois arquivos | bat711 | Programação Shell Script e | 3 | 10-05-2005 02:26 |
| Combinando arquivos | Enda Martin | UNIX para Dummies Perguntas & Respostas | 2 | 07-20-2001 11:31 |
| combinando arquivos | apalex | UNIX para Dummies Perguntas & Respostas | 3 | 06-19-2001 10:49 |
![]() |
|
|
Linkback | Thread Tools | Pesquisar este Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Estou tentando combiná-lo usando awk, mas ainda não pode figurar que para fora. Aqui está o arquivo.
gato file1.txt Sr. Smith John Linda gato file2.txt N º 4 Jln Empat Kuala Lumpur N º 213 TMN Bunga Kedah N º 1 sex Bukit Malásia Quero combinar esta ficheiro1 e ficheiro2 modo a saída será: Sr. Smith N º 4 Jln Empat Kuala Lumpur John N º 213 TMN Bunga Kedah Linda N º 1 sex Bukit Malásia Alguém por favor me ajude ... ![]() |
|
||||
|
Citação:
script: #! / bin / sh Data1 \u003d file1.txt DATA2 \u003d file2.txt awk-f 'BEGIN ( while ((getline < " '$ DATA2'")> 0) f2array [$ 2] \u003d $ 1 OFS \u003d","} (if (f2array [$ 1]) imprimir f2array [$ 1], $ 2, $ 3, $ 4, $ 5 ) '$ Data1 Obrigado pelo seu tempo para ler a minha discussão Franklin ![]() |
|
||||
|
Supondo que as linhas não são separados por uma linha em branco em seus arquivos:
Código:
awk '{
print
getline s < "file2.txt"; print s
getline s < "file2.txt"; print s
print ""
}' file1.txt
Última edição por Franklin52; em 05/27/2009 09:21.. Motivo: ajustar código |
|
||||
|
se você tiver o Python
Código:
#!/usr/bin/env python
file1=open("file1").read().split("\n")
file1=[i for i in file1 if i.strip() !="" ]
file2=open("file2").read().split("\n\n")
for item in zip(file1,file2):
print item[0],"\n",''.join(item[1]),"\n"
Código:
# ./test.py Mr Smith No 4 Jln Empat Kuala Lumpur Mr John No 213 Tmn Bunga Kedah Ms Linda No 1 Kampung Bukit Malaysia |
|
||||
|
Citação:
![]() |
![]() |
| Marcadores |
| Thread Tools | Pesquisar este Thread |
| Display Modes | Esta taxa Thread |
|
|