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

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -