shell脚本+匹配单词没有echo命令


0

以下测试语法是ksh脚本的一部分

   [[ $PARAM = TRUE ]] &&  [[ ` echo $LINE_FROM_FILE | grep -c Validation ` -eq 1 ]] && print "find Validation word"

我是否可以获得一些其他创造性语法/解决方案/命令来验证LINE_FROM_FILE中是否存在验证字而不使用echo命令?

LINE_FROM_FILE =“123验证V125 tcp IP = 1.2.56.4”

利迪娅

Answers:



0

如果“来自文件的行”中的单词分隔符始终是一个或多个空格,请尝试以下操作:

if [[ " $LINE_FROM_FILE " == *" Validation "* ]] 

不要忘记引号

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.