bash - Too many arguments in find -


#!/bin/bash  read dir read search  if [ `find $dir -type f -exec grep $search /dev/null {} \;` ];     echo "find" fi 

what wrong in code? have error: many arguments

[ or [[ or test aren't part of if shell structure commands provided comparisons.

you try :

#!/bin/bash  read dir read search  [[ $(find "$dir" -type f -exec grep "$search" {} \;) ]] && echo "find" # or [[ -n $(find "$dir" -type f -exec grep "$search" {} \;) ]] && echo "find" # or [[ $(find "$dir" -type f -exec grep "$search" {} \;) != "" ]] && echo "find" 

you try :

if [[ $(find "$dir" -type f -exec grep "$search" {} \;) ]];     echo "find" fi 

otherwise, not forget redirection operator before /dev/null.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -