我正在尝试创建一个简单的 shell 脚本,以使我更容易在本地 MAMP Web 开发环境中添加/设置新站点。我有以下脚本,但是需要添加到我的 VHOSTS.conf 文件末尾的文本包含双引号,并且在尝试写入文件时会引发错误。当需要附加的字符串包含双引号时,如何将文本添加到文件末尾?
clear
echo "Enter the name of the dev site you want to add (ie: mysite.dev): "
read devname
echo "Enter the name of the directory where your site lives (ie: /Volumes/Clients/AIA/Website/Dev/): "
read directory
echo "$directory is what you typed in. Your record will be added"
echo '<VirtualHost *:8888>
ServerName $devname
DocumentRoot "$directory"
<Directory "$direcotry">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>' >> /Applications/MAMP/conf/apache/vhosts.conf
echo ""
echo "Your record has successfully been added for $devname