Bashスクリプトから複数のテキストを読む

Bashスクリプトから複数のテキストを読む

graphvizbashスクリプトに変換したい次のスクリプトがあります。

#!/bin/bash  
graph=$(cat <<GRAPHEND
graph match { 
    node[style=filled shape=point label= ""];
    size="40.0,40.0";
    fontsize=10.0;
    overlap=false ;
    spline=true; 
    nodesep=4.0;
    "aaa" -- "aab" [penwidth=2.25 color="red" label="4" fontsize=7.0];
} GRAPHEND
)
echo $graph
#neato -Tpng $graph > graph.png

この試みは、次のエラーによって失敗します。

./high_match.dot: line 2: unexpected EOF while looking for matching `)'
./high_match.dot: line 11: syntax error: unexpected end of file

PS:2行目の行番号は、私がそこでファイルを編集したので正確ではないかもしれません。

ベストアンサー1

GRAPHEND新しい行にする必要があります。

#!/bin/bash  
graph=$(cat <<GRAPHEND
graph match { 
    node[style=filled shape=point label= ""];
    size="40.0,40.0";
    fontsize=10.0;
    overlap=false ;
    spline=true; 
    nodesep=4.0;
    "aaa" -- "aab" [penwidth=2.25 color="red" label="4" fontsize=7.0];
}
GRAPHEND
)
echo $graph

おすすめ記事