0

Solarisでteeコマンドを使用して、1つのコマンドの出力をそれぞれが複数のステートメントで構成される2つの異なるスチームにルーティングしようとしています。これが私がコーディングしたもののスニペットですが、機能しません。この反復により、予期しないファイルの終わりに関するエラーがスローされます。>を|に変更すると 予期しないトークンの近くでエラー構文エラーがスローされます。

todaydir=/some/path
baselen=${#todaydir}

grep sometext $todaydir/somefiles*

while read iline
tee
>(
# this is the first block
do ojob=${iline:$baselen+1:8}
   echo 'some text here' $ojob
done  > firstoutfile
)
>(
# this is the 2nd block
do ojob=${iline:$baselen+1:8}
   echo 'ls -l '$todaydir'/'$ojob'*'
done  > secondoutfile
)

提案?

4

2 に答える 2

1

「 」は、各置換の外側ではなく、内側whileで開始(および終了)する必要があります。したがって、私はあなたが望むものは次のとおりだと信じています。>( ... )

todaydir=/some/path
baselen=${#todaydir}

grep sometext $todaydir/somefiles* | tee >(
   # this is the first block
   while read iline
   do ojob=${iline:$baselen+1:8}
      echo 'some text here' $ojob
   done  > firstoutfile
  ) >(
   # this is the 2nd block
   while read iline
   do ojob=${iline:$baselen+1:8}
      echo 'ls -l '$todaydir'/'$ojob'*'
   done  > secondoutfile
  )
于 2011-10-21T18:01:36.627 に答える
0

私はコマンドがそれをすることはないと思いますtee。このteeコマンドは、stdinを1つ以上のファイルに書き込み、それをstdoutに吐き出します。さらに、あなたが試みているように、シェルがコマンドパイプラインの2つのサブプロセスをフォークできるかどうかはわかりません。Perlのようなものを使用して、いくつかのサブプロセスをフォークし、それぞれにstdinを書き込む方がおそらく良いでしょう。

于 2011-10-21T18:01:29.803 に答える