The UNIX and Linux Forums  

Go Back   UNIXおよびLinuxフォーラム > トップフォーラム > シェルプログラミングとスクリプティング
Googleのunix.com



シェルプログラミングとスクリプティング KSH 、 CSH 、 shに、 bashの、はPerl 、 PHPは、削除するsed 、 Awkの、他のシェルスクリプトやシェルスクリプト言語についての質問の投稿はこちら。

その他のUNIXおよびLinuxフォーラムトピックは参考にすること
スレッド スレッドスターター フォーラム 返信 最後の投稿
先頭およびフォーマットからの出力の出力をキャプチャ new2ss シェルプログラミングとスクリプティング 4 2009年2月24日 09:26午後
出力フォーマット-私との比較/ pファイル velappangs シェルプログラミングとスクリプティング 1 2008年4月3日 07:31午前
ASCII形式のファイルを読みやすい形式に変換するには多 gaur.deepti UNIXのダミー質問と回答のため 5 2008年3月25日 03:03午後
ファイル形式の問題:出力sqlplus deepakgang UNIXのダミー質問と回答のため 2 2007年10月25日 04:56午前
ファイル形式の出力 getdpg シェルプログラミングとスクリプティング 9 2006年1月24日 12:50午後

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

参加日: 2009年6月
投稿数: 6
ファイルからのフォーマットは、出力

やあ、
私は形式には、ファイルに出力availbleされている必要があります
ファイルが出力されます
以下は、ラムProcess_Schedulerされているサーバで実行しているドメインのPC
VPORCL
以下は、アプリケーションサーバーは、サーバーで実行しているドメインラムのPC
VPORCL01
VPORCL02

これらの値VPORCL 、 VPORCL01 ...動的な値を私は、このフォーマットを自分のINTを印刷する必要がある

ホスト名、ドメイン名domaintype
ラムのPC Process_Scheduler VPORCL
ラムPCアプリケーションサーバーVPORCL01
ラムPCアプリケーションサーバーVPORCL02

事前にthanxs
  #2固定リンク)  
Old 2009年7月2日
palsevlohit_123 palsevlohit_123 is offline
登録ユーザー
  
 

参加日: 2008年8月
場所:インドチェンナイ
投稿数: 120
この..を試してみる

コード:
NoOfWords=0
while read LINE
do
        NoOfWords=`echo $LINE|wc -w|awk '{print $1}'`
        #echo "NoOfWords : [$LINE][$NoOfWords]"
        if [ "$NoOfWords" -eq "1" ]
        then
                echo "$OutString " " $LINE"
        elif [ "$NoOfWords" -eq "10" ]
        then
                OutString=`echo $LINE|awk '{printf "%s %s", $10,$4}'`
        elif [ "$NoOfWords" -eq "11" ]
        then
                OutString=`echo $LINE|awk '{printf "%s %s %s", $11,$4,$5}'`
        fi
done < Filename

注:ファイル名の代わりに、入力ファイル名を与える必要がある。
  #3固定リンク)  
Old 2009年7月3日
kshji's Avatar
kshji kshji is offline
登録ユーザー
  
 

参加日: 2009年6月
場所:フィンランド
投稿数: 236
Awkのような外部プログラムを使用して行うことなく。
第1版は、一般的な回線から余分なデータを削除しています。
コード:
#!/usr/bin/ksh
while read id restline
do
        case "$restline" in
                "") # only id, so print line
                    print "$prevheader $id"
                    ;;
                *)  # long line, remove constant/extra strings
                    str=${restline/are the/}
                    str=${str/running in the server/}
                    str=${str/[Dd]omains/}
                    # what we have ? Values
                    prevheader=$str
                    ;;
        esac
done < input.txt
そして、この場合にして、ソリューションを提供します。フィールドの順序を変更する必要があります
コード:
print "____________________________________________________"
# change fld order
while read id restline
do
        case "$restline" in
                "") print "$prevheader $id" ;;
                *)  str=${restline/are the/}
                    str=${str/running in the server/}
                    str=${str/[Dd]omains/}
                    # fields to array flds
                    set -A flds -- $str
                    lastfld=${#flds[*]}
                    # first id = 0
                    ((lastfld-=1))
                    # last field value
                    prevheader=${flds[$lastfld]}
                    ((lastfld-=1))
                    # rest fields
                    fld=0
                    while ((fld<=lastfld))
                    do
                          prevheader="$prevheader ${flds[$fld]}"
                          ((fld+=1))
                    done
                    ;;
        esac
done < input.txt
  #4固定リンク)  
Old 2009年7月3日
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
モデレータ
  
 

参加日: 2003年10月
場所: -31.96,115.84
投稿数:1409
または...
コード:
awk -F '(Following are the |[dD]omains running in the server )' 'NF>1{x=$3 OFS $2}NF==1{print x $1}' file1
...が...
コード:
Ram-pc Process_Scheduler VPORCL
Ram-pc Application Server VPORCL01
Ram-pc Application Server VPORCL02
  #5固定リンク)  
Old 2009年7月3日
thanhdat's Avatar
thanhdat thanhdat is offline
登録ユーザー
  
 

参加日: 2008年8月
場所:パリ
投稿数: 107
私のソリューションよりも長いですが、 ū ygorしてみてください^ _ ^

コード:
awk '{ if(NF==1) printf ("%s %s\n", text, $NF);else if (NF==10) text = $10 OFS $4; else if(NF==11)  text = $11 OFS $4 OFS $5; }' test.txt
  #6固定リンク)  
Old 2009年7月5日
summer_cherry summer_cherry is offline Forum Advisor  
登録ユーザー
  
 

参加日: 2007年6月
所在地:中国北京
投稿数:1088
コード:
my($type,$name);
while(<DATA>){
	if(/.*the\s+(.*)\s+[Dd]omains.*server\s+(.*)/){
		$type=$1;
		$name=$2;
		next;
	}
	print $name," ",$type," ",$_;
}
__DATA__
Following are the Process_Scheduler Domains running in the server Ram-pc
VPORCL
Following are the Application Server domains running in the server Ram-pc
VPORCL01
VPORCL02
Reply

ブックマーク

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

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

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

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




すべてGMT -4です。現在の時刻は 09:31午前


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

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