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
Post a Comment