![]() |
Helloやアメリカ合衆国へようこそ! UNIXおよびLinuxフォーラム!訪問し、当社のグローバルコミュニティに参加いただきありがとうございます。
|
|
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午前 |
|
|
LinkBack | スレッドツール | このスレッドを検索 | スレッドを評価 | 表示モード |
|
||||
|
ループ列を出力
私は必要なのは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 ---------------------------------------------------------------- ありがとう! |