I've got a parent folder with a series of 'histogram_0000_0000' folders inside it. I'm trying to make a bash script that searches for the file 'out.txt' in each folder, and returns for each time it finds the file in a folder (to check that the file exists in all folders). The script I've got is;
#!/bin/bash joblist='job_list.txt' njobs=`wc ${joblist} | awk '{print $1}'` cwd=`pwd` for ((i=1 ; i <= ${njobs} ; i++ )); do folder=`awk '(NR=='${i}'){print}' ${joblist}` echo $folder cd ${folder} if [ find -name "out.txt" ] then echo out.txt found in $folder fi cd ${cwd} done But every time it runs I get an error;
./checkrun.sh: line 10: [: -name: binary operator expected
I've had a look around, tried using '[[' and ']]', but still don't know why I'm having any luck! Any help would be great. Thanks, -Jake