i wrote a bash script that suppose to create some files and write to them. anyway it doesnt really matter what the script does, the thing is - there is a comment in the code (at the end) which suppose only to print something to screen. and if I try to run it like that- the program doesnt write output in the files, but if put this line not as a comment (i.e remove the '##' ) then it works- the program writes the ouput to files. I reallly tried but i dont understand whats going on... If u need the rest of the script, or some more explanation about what it does just say.
files=( `ls $artists` )
echo artists=%${files[*]}%
for file in ${files[*]}; do
echo file= $file:
lines=`wc -l $artists/$file | cut -d" " -f1`
echo lines=$lines
counter=0
while read -a line; do
if (( $counter==$lines ));then
break;
fi
if [[ ! $line =~ [^[:space:]] ]] ; then
continue
fi
rank=$(( ${line[3]}+$(( 5*${line[4]} )) ))
echo ${line[*]}
echo rank = $rank
echo "${line[*]} $rank" >> $artists/$file
let counter++
done < $artists/$file
##cat $artists/$file | tail -$lines
cat $artists/$file | tail -$lines > $artists/$file
done