[svlug] Need a shell/bash loop over each partition and execute dd && rm

Rick Moen rick at linuxmafia.com
Mon Aug 1 21:09:32 PDT 2011


Quoting John Sokol (john.sokol at gmail.com):

> Make sure the list of partitions looks correct.

If you'll pardon brief kibbitzing, here's a very minor refinement to your
script, to exclude various abstract or odd Linux filesystems, in
addition to the df header line with the word 'Available' in it:

#!/bin/bash
for h in $( `df | egrep -v 'Available|tmpfs|udev|ramfs|romfs|cramfs|debugfs' | \
awk '{print $NF}'`   );do
   echo "Cleaning partition $h"
   sudo dd if=/dev/zero of=$hzerofile && sudo rm $hzerofile
done

Only the udev and tmpfs ones are likely to be common problems, but 
I threw in the others just in case.  




More information about the svlug mailing list