linux - 'bash -c' 有什么作用?

标签 linux bash

我遵循以下教程:http://davidtsadler.com/archives/2012/06/03/how-to-install-magento-on-ubuntu/

在某些时候它告诉我执行以下命令:

sudo bash -c "cat >> /etc/apache2/sites-available/magento-store.com <<EOF
<VirtualHost *:80>

  ServerName  localhost.magento-store.com
  ServerAlias www.localhost.magento-store.com

  DocumentRoot /home/dev/public_html/magento-store.com/public

  LogLevel warn
  ErrorLog  /home/dev/public_html/magento-store.com/log/error.log
  CustomLog /home/dev/public_html/magento-store.com/log/access.log combined

</VirtualHost>
EOF"

这个命令做了什么,我怎样才能取消它?

我重新启动了计算机,它似乎仍在运行。我查看了.bashrc.profile,但是里面没有找到。

最佳答案

引用 man bash:

-c string If the -c option is present, then commands are read from string.
If there are arguments after the string, they are assigned to the positional parameters, starting with $0.

您引用的命令会将 heredoc 中的文本(即 VirtualHost 标记中的文本)追加到文件 /etc/apache2/sites-available/magento-store.com.

关于linux - 'bash -c' 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20858381/

相关文章:

c - 在 c, linux 中,关于 kill 和 raise

linux - 将文件重命名为 md5 sum + 扩展名 (BASH)

bash - 如何使用awk在列周围添加单引号

linux - 查找字符串并将替换的字符串存储在其他文件 shell 脚本中

linux - Bash -c awk 给出不同的结果

bash - 使用 sh 解释器运行时读取用户输入的脚本未运行

linux - 模块/v7_flush_dcache_all 中的未知符号在 linux 内核模块中未定义

linux - 如何过滤掉文件中的所有唯一行?

c - 使用 system() 执行 shell 脚本返回 256。这是什么意思?

Linux/Bash,使用 ps -o 按特定名称获取进程?