How to overwrite the data in a file with bash

Posted by Stefan Liebenberg on Stack Overflow See other posts from Stack Overflow or by Stefan Liebenberg
Published on 2010-04-15T09:45:26Z Indexed on 2010/04/15 10:03 UTC
Read the original article Hit count: 530

Filed under:
|
|

I'm writing a bash script that encrypts the data of a folder or file

#!/bin/bash

file_name=$1
tmp_file=/tmp/tmpfile.tar

# tar compress file
tar -cf $tmp_file $file_name;

# encrypt file
gpg -c $tmp_file

# remove temp file
rm -rf $tmp_file $file_name

# mv encrypted file to orignal place
mv ${tmp_file}.gpg $file_name

but the data will still be recoverable by using photorec or similar methods...

Is there a way to ensure the absolute deletion of the original file in bash?

Thank You
Stefan

© Stack Overflow or respective owner

Related posts about bash

Related posts about encryption