其他
这个脚本随机删除系统一半文件,运维必备!
来自:开源最前线(ID:OpenSourceTop)
2019年,钢铁侠死了,美队老了,雷神胖了。这一切,都是因为那个叫 Thanos 的坏蛋!于是,就有程序员写了一个开源的灭霸命令,可随机删除电脑上一半文件。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
#安装gshuf
brew install coreutils
完整脚本如下:
#!/bin/sh
let "i=`find . -type f | wc -l`/2";
if [[ uname=="Darwin" ]]; then
find . -not -name "Thanos.sh" -type f -print0 | gshuf -z -n $i | xargs -0 -- cat;
else
find . -not -name "Thanos.sh" -type f -print0 | shuf -z -n $i | xargs -0 -- cat;
fi
# Explanation
## Step 1: Get the count of files in current path divided by two.
## Step 2: Get all the files in current path and print in one line.
## Step 3: Turn half of the second step output into standard input randomly.
## Step 4: Show half of the files in terminal.
# Key Point
## If you want to make delete, what you need to do is turn 'cat' into 'rm'.
好了,能给的都给你们了,哪天看你们产品经理可以试看看,试玩别忘了告诉我后果是什么,毕竟本脚本功效未经测试,后果有待考证。
本公众号全部博文已整理成一个目录,请在公众号后台回复「m
」获取!