2011-03-10 5 views
0

以下の例では、todel.txtファイルに $ a = b という行があります。 ここでdocテキストブロックを処理せずにそのまま追加するにはどうすればよいですか? "ヒアドキュメント" の周りここで事前処理されたドキュメント

[[email protected]]# cat here_example.sh 
#!/bin/sh 
cat > todel.txt << heredoc 
<?php 
$a=b 
# this is comment 
?> 
heredoc 

[[email protected]]# cat todel.txt 
<?php 
=b 
# this is comment 
?> 

答えて

3

入れ相場:


#!/bin/sh 
cat > todel.txt << "heredoc" 
<?php 
$a=b 
# this is comment 
?> 
heredoc 
+0

Bashのマンページの「Here Documents」を参照してください。 –

1

bash(1) manページから:

word内の任意の文字は を引用している場合は、delimiterはクォート削除の結果でありますwordにあり、here-documentの 行は展開されません。

関連する問題