The UNIX and Linux Forums  
Helloやアメリカ合衆国へようこそ! UNIXおよびLinuxフォーラム!訪問し、当社のグローバルコミュニティに参加いただきありがとうございます。

Go Back   UNIXおよびLinuxフォーラム > スペシャルフォーラム > ダミーな質問&回答のためのUNIXデスクトップ
Googleのunix.com



ダミーな質問&回答のためのUNIXデスクトップ UNIXおよびLinuxのユーザーは、 GNOME 、 KDEを、 CDEのように、とのインターフェイスオープンオフィスはこちら。すべてのUNIXおよびLinux初心者ようこそ! !

その他のUNIXおよびLinuxフォーラムトピックは参考にすること
スレッド スレッドスターター フォーラム 返信 最後の投稿
固定幅の列に区切られたファイルの列の1つの列を変更する manneni prakash シェルプログラミングとスクリプティング 5 2009年6月22日 05:27午前
1つの列を出力用に2つのファイルの違いを比較 samit_9999 UNIXのダミー質問と回答のため 1 2008年4月23日 12:02午後
私たちは' ls 'の列の出力の第5回- l 'の印刷に繋げるtr 'コマンドを使用することができます Nidhi2177 シェルプログラミングとスクリプティング 4 2007年9月17日 06:53午前
サブ。出力の列の数字の場合 ja156194 シェルプログラミングとスクリプティング 11 2007年2月12日 01:52午後
フラグは、列の出力を抑制するため#の行をUNIXでのDB2のSQLで選択した jerardfjay シェルプログラミングとスクリプティング 1 2005年11月2日 06:48午前

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek を搭載 Powered by Google
 
LinkBack スレッドツール このスレッドを検索 スレッドを評価 表示モード
  #1固定リンク)  
Old 2008年11月2日
handband2 handband2 is offline
登録ユーザー
  
 

参加日: 2008年11月
投稿: 5
ループ列を出力

私は必要なのはbashスクリプトを行うために役立つか? I出力するためのテーブルのデータは、コマンドを実行するコマンドに挿入して努力している。データの各列のループ。

例えば、テーブルからの出力データ:

コード:
10 John house
20 Jane apt
30 Joe townhome
それならば、そのデータからの出力を取って別のコマンドに挿入し、必要があるので、私の出力のようになります。例えば:

コード:
-----
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
私がそのコードです:
コード:
#!/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
が出力されます:
コード:
-----------------------------------------------------------------

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 

----------------------------------------------------------------
手伝ってくれる誰かがこの方法のポイントを私に行くか?

ありがとう!
 

ブックマーク

スレッドツール このスレッドを検索
このスレッドを検索

高度な検索
表示モード このスレッド
このスレッド

投稿ルール
あなた ことができない。 新しいスレッドを投稿
あなた ことができない。 返信の投稿
あなた ことができない。 添付ファイルの投稿
あなた ことができない。 自分の投稿を編集

BBコード なる 〜の上に
スマイリー なる 〜の上に
[イメージ] コードは 〜の上に
HTMLコードは、 オフ
トラックバック なる 〜の上に
ピングバック なる 〜の上に
Refbacks なる 〜の上に




すべてGMT -4です。現在の時刻は 11:20午後


提供: vBulletin、著作権© 2000 - 2006、Jelsoft企業株式会社。言語翻訳による電源
vBCredits v1.4著作権© 2007 - 2008 、 PixelFXスタジオ
は、 UNIXおよびLinuxフォーラムのコンテンツ著作権© 1993 〜 2009 。すべての権利を管理しReserved.Ad RedTyger

コンテンツ関連のURLで vBSEO 3.2.0