linux刪除無效鏈接文件腳本分享
Linux終端下執(zhí)行,用于刪除無效的鏈接文件。
#!/bin/sh
usage()
{
echo "RemoveBroken 0.1, a shell script to remove broken link files."
echo "License: MIT, (c) chenzhiqiang"
echo "Usage:"
echo " $0 --help print this help."
echo " $0 --path PATH broken links under this PATH will be removed."
echo " $0 --stdin read PATHs from stdin."
echo " $0 same as $0 --stdin."
}
fromStdin()
{
while [ 1==1 ]
do
read
[ "$REPLY" != "" ] || exit 0
[ ! -L $REPLY -o -e $REPLY ] || unlink $REPLY
done
}
fromPath()
{
find $2 | $0 --stdin
}
if [ $# = 0 ]
then
usage
fromStdin
exit 0
fi
case $1 in
--stdin)
fromStdin
--path)
find $2 | $0 --stdin
--help)
usage
*)
echo "RemoveBroken: unknown usage."
usage
esac
相關(guān)文章
linux下數(shù)據(jù)壓縮的幾種方法與查看方式(示例代碼)
這篇文章主要介紹了linux下數(shù)據(jù)壓縮的幾種方法與查看方式,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-10-10