搜索
查看: 5617|回复: 0

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

[复制链接]

330

主题

177

回帖

1071

积分

vip用户

积分
1071

注册会员活跃会员热心会员

QQ
发表于 2019-5-1 23:15:33 来自手机 | 显示全部楼层 |阅读模式
[pre]
#!/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'.
[/pre]
保存为.sh文件,运行即可!
152653783908900734223-13-13-.jpg
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表