The UNIX and Linux Forums  


Go Back   A UNIX és Linux Forums > Különleges Fórumok > UNIX Desktop dummies Kérdések és válaszok
.
google unix.com



UNIX Desktop dummies Kérdések és válaszok Fórum a UNIX és Linux felhasználói felületek, mint a GNOME, KDE, CDE, és az Open Office ide. Minden UNIX és Linux Newbies Üdvözöljük!

Több, UNIX és Linux fórum témák Ön által talált Hasznos
Szál Thread Starter Fórum Válaszok Utolsó hozzászólás
Megváltoztatása egy oszlopa körülhatárolt file oszlopban rögzített szélességű oszlop manneni Prakash Shell programozás és Scripting 5 06-22-2009 06:27 AM
Összehasonlít 2 kép, hogy egy oszlop és kimeneti különbségek samit_9999 A UNIX a dummies Kérdések és válaszok 1 04-23-2008 01:02 PM
Can we használat "tr" parancs nyomtatott 5. oszlop a teljesítménnyel a "ls-l ' Nidhi2177 Shell programozás és Scripting 4 09-17-2007 07:53 AM
Sub. a számok a kimeneti oszlop, ha ja156194 Shell programozás és Scripting 11 02-12-2007 01:52 PM
flags elnyomni oszlop kimenet, # sorok kiválasztott db2 sql UNIX jerardfjay Shell programozás és Scripting 1 11-02-2005 06:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Téma eszközök Keresés a téma Rate Thread Megjelenítési módok
  #1 (permalink)  
Old 11-02-2008
handband2 handband2 is offline
Regisztrált felhasználó
  
 

Join Date: Nov 2008
Hozzászólások: 5
Loop oszlop kimenet

Tudok segíteni, mit kezdjen a bash script? Próbálom futtatni egy parancsot, hogy a kimeneti adatokat egy táblázatot, majd helyezze vissza a parancsokat. Looping minden sora adatokat.

Például a kimeneti adatokat a táblázat tartalmazza:


Kód:
10 John house
20 Jane apt
30 Joe townhome

Akkor azt kell tennie a kibocsátás az adatok, és helyezzük be a másik parancs, így például én is úgy néz ki, mint teljesítmény:


Kód:
-----
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

A kódot én is:

Kód:
#!/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

Az eredmény:

Kód:
-----------------------------------------------------------------

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 

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

Tud akárki segítsen nekem vagy a pont, ahol tovább hogyan kell ezt csinálni?

Köszönöm!
  #2 (permalink)  
Old 11-03-2008
rubin's Avatar
Rubin rubin is offline Forum Advisor  
Regisztrált felhasználó
  
 

Join Date: Nov 2007
Posts: 321
Ön tudja, valami ilyesmi,


Kód:
while read line
 do 
   set -- $line
   # you can also use echo -e 
   printf -- "-----\nThe number of the person is $1\nThe name of the person is $2\n$2 lives in a $3\n"
 done < file

Kimeneti


Kód:
-----
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

Closed Thread

Könyvjelzõk

Téma eszközök Keresés a téma
Keresés a téma:

Részletes keresés
Megjelenítési módok Rate this thread
Rate this thread:

Posting szabályzat
Ön nem post new threads
Ön nem post válaszok
Ön nem post Csatolmányok
Ön nem szerkeszteni az üzeneteidet

BB kód van Be
Smilies vannak Be
[IMG] kód Be
HTML kód Ki
Trackbacks vannak Be
Pingbacks vannak Be
Refbacks vannak Be




Minden idő GMT -4. Az idő most 11:23 AM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Nyelvre lefordítva Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
A UNIX és Linux Fórum Tartalom Copyright © 1993-2009. Minden jog Reserved.Ad menedzsment RedTyger

Content Relevant URLs by vBSEO 3.2.0