Artificial intelligent assistant

using find in Bash Script and checking if file is present var= "$(find . -name 'gen*.bt2')" if [ "$var" == "" ] then echo bad else echo great fi I get errors **./script.sh: line 4:** ./gen.4.bt2 ./gen.rev.1.bt2 ./gen.rev.2.bt2 ./gen.1.bt2 ./gen.3.bt2 ./gen.2.bt2: **No such file or directory** great However, when I run the same code in terminal, files are listed perfectly, without any error. Can someone correct me, where am I going wrong? I need to check, if certain files are present or not, if present then proceed.

The problem is the space in your assignment. The shell is whitespace-sensitive. Your command is the equivalent of:


var="" "./gen.4.bt2 ./gen.rev.1.bt2 ./gen.rev.2.bt2 ./gen.1.bt2 ./gen.3.bt2 ./gen.2.bt2" # output of find


You need to remove the space:


var="$(find . -name 'gen*.bt2')"

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ec42fe182f9583e5f962be933053b287