tags:

views:

78

answers:

4

lets say we were to use standard bash terminology to write a for loop which loops srm to securely erase a item on your drive.

Now lets say we set it to iterate 10 times, after it is done the first iteration, How can it still work on the file? The file should no longer exist, so how can It erase it? Not a question specific to srm, anything can be ran. Even something like mv, even when the file is no longer availible.

+2  A: 

srm does the looping for you, and then deletes the drive, there is no need or ability to do what you want from bash. You would have to write something in C/C++ that talked directly to the filesystem using some OS specific API.

fuzzy lollipop
+3  A: 

It'll run through the loop 10 times, but except on the first iteration, the command you're executing will fail (and return -1). The command will also write out any error messages it normally writes out (to stdout, stderr or a file).

#!/bin/bash
for i in {1..5}
do
    rm something
done

Now, assuming there's a file called something, you get:

rm: something: No such file or directory
rm: something: No such file or directory
rm: something: No such file or directory
rm: something: No such file or directory

Note that this happens 4 times, not 5, since the first time, rm ran successfully.

Chinmay Kanchi
+1  A: 

Overkill. Just use shred --remove <file>; it's a dozen times easier.

If you're trying to wipe your whole drive, it's been pretty systematically proven that nothing gets you more bang for the buck than dd and writing your drive with zeroes.

John Feminella
+3  A: 

You can't. Once srm has returned, the file is gone.

Rather then writing a loop, you will want to adjust the arguments to srm to overwrite the data more times before returning.

According to the Wikipedia writeup on srm, the default mode is 35 pass Gutmann. Is that really not sufficient?

R Samuel Klatchko