次のような「align_summary.txt」というファイルがあります。
Left reads:
Input : 26410324
Mapped : 21366875 (80.9% of input)
of these: 451504 ( 2.1%) have multiple alignments (4372 have >20)
...more text....
... and several more lines of text....
bash シェルで、すべての左揃えの読み取り (この場合は 2.1) の中で、複数の配置の割合を引き出したいと考えています。
私がこれを使用する場合:
pcregrep -M "Left reads.\n..+.\n.\s+Mapped.+.\n.\s+of these" align_summary.txt | awk -F"\\\( " '{print $2}' | awk -F"%" '{print $1}' | sed -n 4p
すぐに出力が得られます:2.1
ただし、同じ式を次のようにバッククォートで囲むと:
leftmultiple=`pcregrep -M "Left reads.\n..+.\n.\s+Mapped.+.\n.\s+of these" align_summary.txt | awk -F"\\\( " '{print $2}' | awk -F"%" '{print $1}' | sed -n 4p`
エラーが表示されます:
awk: syntax error in regular expression ( at
input record number 1, file
source line number 1
私が理解しているように、この式をバッククォートで囲むと、バックスラッシュでエスケープされているにもかかわらず、「(」記号を含む正規表現の解釈に影響します。
これが発生する理由と、このエラーを回避する方法を教えてください。
ご意見やご提案をいただければ幸いです。
どうもありがとう、