The UNIX and Linux Forums  
Olá e boas-vindas de Estados Unidos para o UNIX e Linux Forum! Obrigado por visitar e fazer parte da nossa comunidade global.

Go Back   O UNIX e Linux Forum > Especial Fóruns > UNIX desktop para Dummies Perguntas & Respostas
.
google unix.com



UNIX desktop para Dummies Perguntas & Respostas Discuta UNIX e Linux user interfaces como o GNOME, KDE, CDE, e Open Office aqui. Todos os UNIX e Linux Newbies Bem-vindo!

Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
Fio Thread Starter Fórum Respostas Última postagem
Alterando uma coluna do arquivo delimitado coluna para coluna de largura fixa manneni Prakash Programação Shell Script e 5 06-22-2009 05:27
Comparar 2 ficheiros para uma única coluna e saída diferenças samit_9999 UNIX para Dummies Perguntas & Respostas 1 04-23-2008 12:02
Podemos usar 'tr' comando para imprimir 5a coluna da saída do 'ls-l' Nidhi2177 Programação Shell Script e 4 09-17-2007 06:53
Sub. números na coluna de produção com Se ja156194 Programação Shell Script e 11 02-12-2007 01:52
bandeiras para suprimir a coluna de saída, n º de linhas seleccionadas em db2 sql no UNIX jerardfjay Programação Shell Script e 1 11-02-2005 06:48

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
Linkback Thread Tools Pesquisar este Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-02-2008
handband2 handband2 is offline
Usuário
  
 

Join Date: Nov 2008
Posts: 5
Loop coluna de saída

Preciso de ajuda para o que fazer com um bash script? Estou tentando executar um comando para saída de dados de uma tabela e insira-o em comandos. Looping para cada linha de dados.

Por exemplo, a saída de dados de uma tabela:

Código:
10 John house
20 Jane apt
30 Joe townhome
Então eu preciso para tomar a saída dos dados e inseri-la em um outro comando, assim como por exemplo a minha saída seria algo parecido com:

Código:
-----
The number of the person is 10
The name of the person is John
John lives in a house
-----
The number of the person is 20
The name of the person is Jane
Jane lives in a apt
-----
The number of the person is 30
The name of the person is Joe
Joe lives in a townhome
O código que tenho é:
Código:
#!/bin/bash

echo
echo "-----------------------------------------------------------------"

DATA=`cat data.txt`

for i in $DATA; do

    NUM=$(echo $i |awk '{print $1}');
    NAME=$(echo $i |awk '{print $2}');
    LOC=$(echo $i |awk '{print $3}');    

    echo "The number of the person is $NUM"
    echo "The name of the person is $NAME"
    echo "$NAME lives in a $LOC"

echo
echo "-----------------------------------------------------------------"
echo
done
A saída é:
Código:
-----------------------------------------------------------------

The number of the person is 10
The name of the person is 
 lives in a 

-----------------------------------------------------------------


The number of the person is John
The name of the person is 
 lives in a 

-----------------------------------------------------------------


The number of the person is house
The name of the person is 
 lives in a 

-----------------------------------------------------------------


The number of the person is 20
The name of the person is 
 lives in a 

-----------------------------------------------------------------


The number of the person is Jane
The name of the person is 
 lives in a 

-----------------------------------------------------------------


The number of the person is apt
The name of the person is 
 lives in a 

-----------------------------------------------------------------


The number of the person is 30
The name of the person is 
 lives in a 

-----------------------------------------------------------------


The number of the person is Joe
The name of the person is 
 lives in a 

-----------------------------------------------------------------


The number of the person is townhome
The name of the person is 
 lives in a 

----------------------------------------------------------------
Alguém pode me ajudar ou o ponto para onde ir sobre como fazer isso?

Obrigado!
 

Marcadores

Thread Tools Pesquisar este Thread
Pesquisar este Thread:

Pesquisa Avançada
Display Modes Esta taxa Thread
Esta taxa Thread:

Destacamento Regimento
Você não pode postar novas threads
Você não pode postar respostas
Você não pode postar anexos
Você não pode editar suas postagens

BB code é Ligado
Smilies são Ligado
[IMG] código é Ligado
Código HTML é Desligado
Trackbacks são Ligado
Pingbacks são Ligado
Refbacks são Ligado




Todos os horários são GMT -4. A hora é agora 06:37.


Powered by: vBulletinCopyright © 2000 - 2006, Jelsoft Enterprises Limited. Língua Traduções Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
O UNIX e Linux Fóruns Content Copyright © 1993-2009. Todos os Direitos Reserved.Ad Gestão por RedTyger

Content Relevant URLs por vBSEO 3.2.0