0

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.

1
  • can you put it more clearly what you want to do? you said you want to run mv (example) in a for loop. Then you want to operate again on the files that are moved ? Commented Feb 2, 2010 at 1:23

4 Answers 4

3

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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?

Comments

2

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.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.