libo 发表于 2019-5-1 23:15:33

一个响指 随机删除电脑中一半文件


#!/bin/sh
let i=`find . -type f | wc -l`/2 ; find . -type f -print0 | shuf -z -n $i | xargs -0 -- cat

# Explaination
## 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'.

保存为.sh文件,运行即可!
页: [1]
查看完整版本: 一个响指 随机删除电脑中一半文件