Created
February 8, 2022 18:47
-
-
Save pmarreck/46612cbc03a30c39ae485f8ca6c29635 to your computer and use it in GitHub Desktop.
destroy a random half of your files, Thanos-style, in linux or bash shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wrote this on a whim. Consider it performance-art shell scripting. | |
# To really do this, set FFS=true, otherwise, only the paths to the files that would have been destroyed are printed. | |
# I take no responsibility for the use of this. Even writing it was scary, and I didn't test the whole thing (YET). | |
# You have been warned. | |
coinflip() { return $(($RANDOM%2)); } | |
thanos_logic() { while read -r line; do coinflip && echo "$line"; done; } | |
thanos_infinity_gauntlet_completed() { | |
if [ "$FFS" ]; then | |
sudo find / -type f | thanos_logic | xargs -P 16 -n 1 -r -d '\n' shred -fu | |
else | |
sudo find / -type f | thanos_logic | xargs -r -d '\n' printf "%s\n" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment