4#已經征得作者的同意.56#一個用于發現死符號鏈接并且輸出它們的鏈接文件的純shell的腳本。7#所以它們能把輸出提供給xargs并處理8#例如:broken-link.sh/somedir/someotherdir|xargsrm9#10#下面是更好的發現死符號鏈接的辦法:11#12#find"somedir"-typel-" />

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

測試斷掉的連接

系統 2010 0
? 1 #!/bin/bash
?? 2 # broken-link.sh
?? 3 # 由Lee bigelow所寫<ligelowbee@yahoo.com>
?? 4 # 已經征得作者的同意.
?? 5
?? 6 #一個用于發現死符號鏈接并且輸出它們的鏈接文件的純shell的腳本。
?? 7 #所以它們能把輸出提供給xargs并處理
?? 8 #例如: broken-link.sh /somedir /someotherdir|xargs rm
?? 9 #
? 10 #下面是更好的發現死符號鏈接的辦法:
? 11 #
? 12 #find "somedir" -type l -print0|\
? 13 #xargs -r0 file|\
? 14 #grep "broken symbolic"|
? 15 #sed -e 's/^\|: *broken symbolic.*$/"/g'
? 16 #
? 17 #但這不是純bash腳本,下面的則是.
? 18 #注意: 謹防在/proc文件系統和死循環鏈接中使用!
? 19 ##############################################################
? 20
? 21
? 22 #如果沒有參數被傳遞給腳本作為搜索目錄,則使用當前目錄
? 23 #
? 24 #
? 25 ####################
? 26 [ $# -eq 0 ] && directorys=`pwd` || directorys=$@
? 27
? 28 #Setup the function linkchk to check the directory it is passed
? 29 #for files that are links and don't exist, then print them quoted.
? 30 #If one of the elements in the directory is a subdirectory then
? 31 #send that send that subdirectory to the linkcheck function.
? 32 ##########
? 33 linkchk () {
? 34???? for element in $1/*; do
? 35???? [ -h "$element" -a ! -e "$element" ] && echo \"$element\"
? 36???? [ -d "$element" ] && linkchk $element
? 37???? # Of course, '-h' tests for symbolic link, '-d' for directory.
? 38???? done
? 39 }
? 40
? 41 #Send each arg that was passed to the script to the linkchk function
? 42 #if it is a valid directoy.? If not, then print the error message
? 43 #and usage info.
? 44 ################
? 45 for directory in $directorys; do
? 46???? if [ -d $directory ]
? 47 then linkchk $directory
? 48 else
? 49 ??? echo "$directory is not a directory"
? 50 ??? echo "Usage: $0 dir1 dir2 ..."
? 51???? fi
? 52 done
? 53
? 54 exit 0

測試斷掉的連接


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 陆良县| 鹤壁市| 新昌县| 麻栗坡县| 会昌县| 邹平县| 北流市| 东源县| 日照市| 昭平县| 南皮县| 塔城市| 临桂县| 黑河市| 武川县| 宁陕县| 威海市| 五家渠市| 桐庐县| 马公市| 淮安市| 汉川市| 阿拉善盟| 黄浦区| 正宁县| 苗栗县| 铜山县| 淮阳县| 福泉市| 中阳县| 湖州市| 科技| 兰西县| 肃南| 大兴区| 拜城县| 鹿泉市| 岑溪市| 天气| 年辖:市辖区| 扬中市|