保持简单:)
grep + echo 应该足够了:
grep -qxF 'include "/configs/projectname.conf"' foo.bar || echo 'include "/configs/projectname.conf"' >> foo.bar
-q
安静-x
整行匹配-F
模式是一个普通的字符串- https://linux.die.net/man/1/grep
编辑:合并@cerin和@ thijs-wouters建议 。

保持简单:)
grep + echo 应该足够了:
grep -qxF 'include "/configs/projectname.conf"' foo.bar || echo 'include "/configs/projectname.conf"' >> foo.bar
-q安静
-x整行匹配
-F模式是一个普通的字符串
编辑:合并@cerin和@ thijs-wouters建议 。