我想执行以下命令:
awk '{print "1" $0}' /path_toFile/file.txt
这是我的代码:
String[] params = new String[3];
params[0] = "/usr/bin/awk";
params[1] = "print \"1\" $0";
params[2] = "/path_toFile/file.txt";
Runtime.getRuntime().exec(params);
获取错误:
Exit Value = 2
syntax error The source line is 1.
The error context is
>>> print <<< \"1\" $0
awk: Quitting
The source line is 1.
答案 0 :(得分:2)
围绕大括号({..}
)缺少代码:
params[1] = "{print \"1\" $0}";