Ah yes, of course. Let me type out the larger picture so you can see how it's working.
The ls.txt is a cut listing of filenames (one filename per line).
As I'm opening each file, which happen to be all fixed-length csv files, I'm cutting the first field and the fifth field.
The following would be an example of two records (each line in each fixed-length csv file is a record with aproximately 32 fields). I have isolated the two fields for you.
Example fields (the forum deletes extra spaces so it would be easier I think if I describe it instead: FIELD1 is in columns 2-4 (a string of 3 letters), and the the second column aka FIELD5 can either be filled with a one digit number (1-9) or a single space (" ").
PHP Code:
while read FILENAME; do
FIELD1=`cut -c2-5 $FILENAME`
FIELD5=`cut -c68 $FILENAME`
if [ $FIELD1 -eq "PBR" && $FIELD5 -eq " " ]; then
$count++
fi
done < ls.txt
I'm kind of thinking that maybe it's not working because... if you try to use the "cut" command and it cuts a single space, maybe the shell doesn't assign anything to the variable?