Question: I have just purchased a new CF card for my DSLR. I tested it using Xbench (Mac OS X) and it performs as expected. However, I'd like to do a "surface scan" (moving platter term) to check for "bad sectors" (moving platter term). I could bash script a processes using dd, but I get the feeling that there is a better way out there. My goal is to conclusively know that a memory card (CF, SD, etc.) is safe to use on a photo shoot, and that is doesn't need to be returned before the 30 day vendor policy window expires.

I definitely want Mac solutions given here. I would also like to get a few Linux suggestions. Let's even throw a bone to the windows users just so that this one question can meet everyone's needs.

Answer: 
In Linux, the command you want is `badblocks`. There appears to be a port of this to Mac OS X as part of [this ext2-for-os-x port](http://sourceforge.net/projects/ext2fsx/) -- install the whole thing and ignore everything but the `/usr/local/sbin/badblocks` command.

That said, this will help test, but I don't think it'll be conclusive, because first as Leonidas says, you don't really get raw access to the flash memory so it's hard to do a complete scan, and also because new failures could appear after the test, perhaps even triggered by it.
I found this on google, I'm not using sd cards for cameras' storage but instead I got my class 10 32 gigs sdhc sandisk completely corrupted after less then 2 years of use on my samsung galaxy S2.

I am using badblocks to see where the first badblocks start and then I will make partitions around that area if possible. this is my current, very very bad solution :/