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

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -

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