我正在尝试自动化我们的应用程序备份.过程的一部分是检查的退出状态egrep中的if语句:
if [ ! -f /opt/apps/SiteScope_backup/sitescope_configuration.zip ] ||
[ egrep -i -q "error|warning|fatal|missing|critical" "$File" ]
then
echo "testing"
fi
Run Code Online (Sandbox Code Playgroud)
我希望它输出,testing因为文件存在并egrep返回成功,但我得到一个错误:
-bash: [: too many arguments
Run Code Online (Sandbox Code Playgroud)
我尝试了各种语法 - 附加括号,引号等但错误仍然存在.
请帮助我理解我哪里出错了.
我正在尝试使用空格分隔我的字符串并提取字符串值的第二个文本。
这是我的代码 -
String title = 'testing abcdefgh.abc.cde.fgh test testing issue'
String[] test = title.split(" ");
String[] newTest = test[1];
println newTest
Run Code Online (Sandbox Code Playgroud)
这是我得到的输出 - [a, b, c, d, ., a, b, c, ., c, d, e, ., f, g, h]
现在我正在寻找的输出是 abcd.abc.cde.fgh,但我得到 [a, b, c, d, ., a, b, c, ., c, d, e, ., f, g , H]
我使用过 ("\s+"), ("\s"),只是括号内的空格,单引号和双引号括起来的空格,没有任何效果。