Search code examples
bashencryptionerase

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?


Solution

  • you can try srm or wipe