The UNIX and Linux Forums  
Ciao e benvenuto da parte degli Stati Uniti al UNIX e Linux Forum! Grazie per la visita ed unirsi alla nostra Comunità Globale.

Go Back   UNIX e Linux Forum > Special Forum > UNIX Desktop for Dummies Domande & Risposte
.
google unix.com



UNIX Desktop for Dummies Domande & Risposte Discuti di UNIX e Linux interfacce utente come GNOME, KDE, CSI, e Open Office qui. Tutti i neofiti di Linux e UNIX Benvenuto!

Più di UNIX e Linux Forum Argomenti potreste trovare utili
Filo Thread Starter Forum Risposte Ultimo Post
Modificare una colonna di file delimitato da colonna a colonna a larghezza fissa manneni Prakash Shell scripting e di programmazione 5 06-22-2009 05:27 AM
Confronta 2 file per una singola colonna e di uscita delle differenze samit_9999 UNIX for Dummies Domande & Risposte 1 04-23-2008 12:02 PM
Possiamo utilizzare 'tr' comando per stampare 5a colonna della produzione di 'ls-l' Nidhi2177 Shell scripting e di programmazione 4 09-17-2007 06:53 AM
Sub. numeri nella colonna di output con Se ja156194 Shell scripting e di programmazione 11 02-12-2007 01:52 PM
bandiere di sopprimere colonna di uscita, numero di righe selezionate nella db2 sql in UNIX jerardfjay Shell scripting e di programmazione 1 11-02-2005 06:48 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Cerca in questo Thread Rate Thread Modalità di visualizzazione
  #1 (permalink)  
Old 11-02-2008
handband2 handband2 is offline
Utente Registrato
  
 

Iscriviti Data: novembre 2008
Interventi: 5
Loop colonna uscita

Ho bisogno di aiuto in quello che a che fare con uno script bash? Sto cercando di eseguire un comando per l'output dei dati da una tabella e poi inserirlo in comandi. Looping per ogni riga di dati.

Ad esempio, l'output di dati da una tabella:

Codice:
10 John house
20 Jane apt
30 Joe townhome
Poi ho bisogno di prendere l'output di dati e di inserirlo in un altro comando, così per esempio il mio output sarà simile:

Codice:
-----
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
Il codice che ho è il seguente:
Codice:
#!/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
L'output è il seguente:
Codice:
-----------------------------------------------------------------

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 

----------------------------------------------------------------
Can anyone help me o il punto dove andare su come farlo?

Grazie!
 

Segnalibri

Thread Tools Cerca in questo Thread
Cerca in questo Thread:

Ricerca Avanzata
Modalità di visualizzazione Vota questo thread
Vota questo thread:

Distacco regolamento
Tu non può post nuovo thread
Tu non può inviare una risposta
Tu non può postare allegati
Tu non può modificare i tuoi post

BB codice è Su
Smilies sono Su
[IMG] codice Su
Codice HTML è Chiuso
Trackbacks sono Su
Pingbacks sono Su
Refbacks sono Su




Tutti gli orari sono GMT -4. La data di oggi è 09:06 AM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Traduzioni Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
UNIX e Linux Forum Content Copyright © 1993-2009. Tutti i diritti Reserved.Ad di gestione da RedTyger

Contenuti pertinenti URL da vBSEO 3.2.0