Conditional in shell

前端 未结 2 649
一个人的身影
一个人的身影 2021-01-28 16:56
find . -type f -exec sh -c \'  if [cat ${1} == \"abc\" ]   then  echo ${1} fi\' _ {} \\;

I got this error:

_: -c: line 1: syntax error:         


        
2条回答
  •  梦如初夏
    2021-01-28 17:47

    Put spaces after '[' and before ']' and a ';' after the ']'

    another way is to use

    [ `cat ${1}` == "abc" ] && echo ${1}
    

提交回复
热议问题