Created
July 23, 2013 10:14
-
-
Save shellexy/6061351 to your computer and use it in GitHub Desktop.
RT @o_lll 给大家讲个笑话,有个 ~ 的目录于是想都没想就 rm -rf ~ 了。。。 13:09:10 发自: Echofon
This file contains hidden or 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
#!/bin/bash | |
# 防止删除过浅目录(浅的可能比较重要 | |
args=() | |
for i in "$@" | |
do | |
fn=$(readlink -m -- "$i" 2>/dev/null) | |
[ -z "${fn##/*/*/*/*}" -o ! -a "$fn" ] && args=("${args[@]}" "$i") | |
done | |
/bin/rm "${args[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment