开发者

pre processed here doc

In the example given below, I was expecting the line $a=b in the todel.txt file. How do I add the here doc text block as it is without processing?

[root@localhost]# cat here_example.sh 
#!/bin/sh
cat > todel.txt << heredoc
<?php
$a=b
# this is comment
?>
开发者_JS百科heredoc

[root@localhost]# cat todel.txt 
<?php
=b
# this is comment
?>


Put quotes around "heredoc":


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


From the bash(1) man page:

If any characters in word are quoted, the delimiter is the result of quote removal on word, and the lines in the here-document are not expanded.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜