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, thedelimiter
is the result of quote removal onword
, and the lines in the here-document are not expanded.
#!/bin/sh
cat > todel.txt << "heredoc"
<?php
$a=b
# this is comment
?>
heredoc
精彩评论