UNIX command to format or delete all content on Flash Drive

Need a unix command that will allow me to quickly remove all contents or format a flash drive.

Computers will be OS X based and I would have to batch process them.

I'm just looking for the command itself, then my other guys can automate them

Thanks

G4 Dual 800, PowerBook 15 SuperDrive, iBook 12

Posted on Jul 22, 2006 11:26 AM

Reply
5 replies

Jul 22, 2006 8:31 PM in response to Jeff Kuo

Jeff,
Do you need to take the time to reformat for security or reliability reasons? (diskutil will take a bit longer)
If not then the unix command to remove is "rm", to remove securly (write blank data into the file before remvoing) you can use "srm". (rm will be very fast, srm will take as long as it needs to write all the data)

rm /Volumes/FlashDriveName/*

Needless to say the combination of rm and * make quite a mess. In this case if you get FlashDriveName wrong then all the files on that disk could be gone. For good. Really gone.

Reese

Jul 23, 2006 1:52 PM in response to Mihalis Tsoukalos

Hi Mihalis,
The second of your commands has a risk of failure because some of the directories may not be empty when the attempt is made to delete them. The problem isn't that the command won't try to delete all directories. The problem is that it tries to delete higher level directories before the directories they contain. A depth-first search will remedy that problem. Thus, I recommend the following form of the command:

find -d /Volumes/Flash -type d -exec rmdir {} \;

or

find -d /Volumes/Flash -type d -delete

--
Gary
~~~~
A straw vote only shows which way the hot air blows.
-- O'Henry

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

UNIX command to format or delete all content on Flash Drive

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.