2

我有一个如下所示的 scala 进程命令来使用 linux bash egrep 命令。但是在终端和我的 scala 生成的文件中的搜索结果是不一样的。Scala 结果包含具有“新”和“异常”的所有内容,而我希望输出仅包含具有“新异常”的行。我在这里错过了什么吗?请帮忙

    if (("egrep -r -I -n -E \"*new Exception*\" /mysource/" #| 
            "grep -v .svn").! == 0) {
        out.println(("egrep -r -I -n -E \"*new Exception*\" /mysource/" #| 
            "grep -v .svn").!!)
    }
4

1 回答 1

3

文档说(在“运行什么以及如何运行”下):Implicitly, each process is created either out of a String, with arguments separated by spaces -- no escaping of spaces is possible -- or out of a scala.collection.Seq, where the first element represents the command name, and the remaining elements are arguments to it. In this latter case, arguments may contain spaces

因此,显然,如果您需要向命令行传递一个带有空格的单个参数,例如new Exception,您需要从 aSeq而不是单个String.

于 2012-11-19T21:32:22.340 回答