![]() |
|
|
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 |
| Novo para scripting, Precisa de ajuda | newbie22102 | Programação Shell Script e | 2 | 02-25-2008 11:08 |
| scripting ajudar | james94538 | Programação Shell Script e | 2 | 02-08-2008 07:36 |
| diferença entre AIX e Unix shell scripts shell scripts. | haroonec | Programação Shell Script e | 2 | 04-12-2006 09:12 |
| scripting guru da pls me ajudar com scripting no AIX | thatiprashant | Programação Shell Script e | 1 | 01-20-2006 07:58 |
| Ksh Scripting | dstaller | Programação Shell Script e | 1 | 11-16-2005 02:30 |
![]() |
|
|
Linkback | Thread Tools | Pesquisar este Thread |
Avaliação:
|
Display Modes |
|
|
|
||||
|
Precisa de Ajuda scripts
Caro Scripting peritos,
Pedido para orientar-me em passar os valores para a coluna rows Exemplo: Arquivo 1: 1, a, b, c, d, e, f, g, h 2, F, G, H, I, L Saída de arquivo 1, a, b, c 1, D, E, F 1, g, h 2, F, G, H 2, i, l Na verdade, eu tentei com o uso e awk sed mas infelizmente eu não poderia obter a resultante. Atenciosamente nani |
|
|||||
|
Utilize nawk / ou usr/xpg4/bin/awk em Solaris: Código:
$ cat file
1,a,b,c,d,e,f,g,h
2,f,g,h,i,l
$ awk -F, '{
printf$1FS;c=0
for(i=2;i<=NF;i++)
printf$i (++c%3?i==NF?RS:FS:RS$1FS)
}' file
1,a,b,c
1,d,e,f
1,g,h
2,f,g,h
2,i,l
|
|
||||
|
Plz descobrir o erro no seguinte código
cut-f 7,34 --d "," first97col.CSV | awk-F \ ', ( if ($ 2 !\u003d"") printf 1FS $ c \u003d 0 for (i \u003d 2; i <\u003d NF; i + +) printf $ i (+ + c% 4? i \u003d\u003d NF? RS: FS: RS $ 1FS) fi; ) ' Última edição por pkumar3; em 10/13/2008 09:41.. |
|
|||||
|
Citação:
Código:
perl -F, -nae'if($#F){s/((?:(?:.*?),){3}[^,]*)/$1\n$F[0]/g;print}' filename
|
|
||||
|
Aqui está uma abordagem bastante simples Python (testado ea funcionar). Código:
$ cat nani123.py
#!/usr/bin/env python
input = open("temp.txt", 'r')
for line in input:
line = line.rstrip()
line = line.split(',')
num = line[0]
data = line[1:]
while data:
print num + "," + ','.join(data[:3])
data = data[3:]
Teste: Código:
$ cat temp.txt 1,a,b,c,d,e,f,g,h 2,f,g,h,i,l $ python nani123.py 1,a,b,c 1,d,e,f 1,g,h 2,f,g,h 2,i,l |
![]() |
| Marcadores |
| Thread Tools | Pesquisar este Thread |
| Display Modes | Esta taxa Thread |
|
|