How to overwrite the data in a file with bash
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?
you can try srm or wipe
I gather it is impossible to just pipe the file into gpg, as you would already have tried that?
This should also work:
rm -Pf file
Can you create a ramdisk to create the temp file in? Alternatively if the data is that sensitive maybe you should be using an encrypted file system?
精彩评论