Php 使用命令行将纯文本插入ubuntu文件

Php 使用命令行将纯文本插入ubuntu文件,php,bash,shell,ubuntu,Php,Bash,Shell,Ubuntu,我在ubuntu机器中输入了xx文件,我试图通过php脚本访问该文件,并在其中插入纯文本。 为了向该文件中插入文本,我使用了包含以下代码的bash文件 echo $1>> xx 此脚本将获取要作为参数插入的文本,并将其插入到 xx文件 为了运行bash文件,我在php中使用了以下代码 header('Content-type: text/plain') ; echo $txt = 'hello \n how are you \n '; s

我在ubuntu机器中输入了xx文件,我试图通过php脚本访问该文件,并在其中插入纯文本。 为了向该文件中插入文本,我使用了包含以下代码的bash文件

 echo $1>> xx
此脚本将获取要作为参数插入的文本,并将其插入到 xx文件

为了运行bash文件,我在php中使用了以下代码

      header('Content-type: text/plain') ;

           echo  $txt = 'hello \n how are you \n ';

 shell_exec ("sudo /bin/bash  /etc/freeradiusbash/append.sh  '".$txt."'"); 
我想在第一行打印你好,在第二行打印你好,但是xx文件的内容是

hello \n how are you \n
如何告诉bash文件将文本打印为纯文本

echo -e "Top line \nBottom line"
Output:  Top line
         Bottom line

如果没有-e标志,则\n将保留为文本。

首先,将
echo$1>>xx
更改为
echo“$1”>>xx
,然后更改

echo  $txt = 'hello \n how are you \n ';


使用双引号代替简单引号使用双引号是否有帮助
$txt=“你好\n你好\n”可能重复我使用双引号,但没有结果
echo  $txt = "hello \nhow are you\n";