我可以使用什么命令检查文件中的指定字符串是否添加到文件的最后一个?

时间:2015-07-09 10:47:51

标签: linux shell

例如: 我想检查一下"服务器代理"存在于文件" aaa",

  1. 如果是,则没有什么可做的;
  2. 如果不是,那么我将添加"服务器代理"到文件的最后一行" aaa"。
  3. 那么我应该如何使用shell命令来实现呢?

    聚苯乙烯。我认为命令require_once "scssphp-0.1.7/scss.inc.php"; use Leafo\ScssPhp\Compiler; use Leafo\ScssPhp\Server; $scss = new Compiler(); $scss->setImportPaths('sass'); //$txt = '$color: yellow;'; $txt = '$font: "Open sans";'; $txt .= '$body-font-size: 15px;'; $txt .= '$containerWidth: 1140px;'; $txt .= '$gutter-size: 15px;'; $txt .= '$primarycolor: red;'; $txt .= '$secondarycolor: blue;'; $txt .= '$background: #e8e3e3;'; $txt .= '$textcolor: $primarycolor;'; $txt .= '$linkcolor: #000;'; $file = fopen('sass/_configuratie.scss', "w"); if (fwrite($file, $txt)) { $server = new Server('sass', null, $scss); $server->serve(); } 可以为第二步提供一些帮助。

1 个答案:

答案 0 :(得分:2)

grep -q "server proxy" aaa || echo "server proxy" >> aaa