這篇文章主要介紹“l(fā)inux刪除無效鏈接文件的腳本分享”,在日常操作中,相信很多人在linux刪除無效鏈接文件的腳本分享問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”linux刪除無效鏈接文件的腳本分享”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
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 0fi case $1 in--stdin) fromStdin--path) find $2 | $0 --stdin--help) usage*) echo "RemoveBroken: unknown usage." usageesac
到此,關(guān)于“l(fā)inux刪除無效鏈接文件的腳本分享”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!