Well, you can find the list of files using find. The -name option will do this:
Code:
find /etc/lp/printers -name comment
You can pipe this into a little shell loop:
Code:
... | while read filename; do ... done
And for each file you could do the test like this. There'll be lots of methods for this. You can use grep (with head), I sure you can use sed too, or any number of methods. I like perl. I use perl.
Code:
perl -ne 'if ( $_ =~ /^U/ ) { exit 0; } else { exit 1; }'
...and then you can test $? to decide what to do with the file.