Linux - Helpfull Bash snipets
Linux snipets
This is a collection of scripts that have proven to be helpful over time, it may also be helpful to you.
Destroying all content of a folder permanently
if you find that you need to delete the content of files (shredding) , but not the whole disk you could run the following snippet.
I find this snippet useful when using systems that do not have shred installed - such as synology NAS boxes.
NOTE: it will delete your data with no way to retrieving it - be sure to use the correct path
find /home/brainpowered/temp/toShred/ -type f -print | while read i; do SIZE=$(stat -c%s "${FILE}") && echo $SIZE && echo "destroying file with size -> $SIZE <- on path -> ${FILE}" && dd if=/dev/urandom of="${FILE}" bs=$SIZE count=1 ; done
the above will overwrite the files contained in this folder with semi-random data; making "almost" impossible to recover their contents.