查找當前目錄以下重複的頭文件並輸出

拷貝以下代碼,保存爲.sh文件執行

#!/bin/bash  
  
dir_arr=$(find -name "*h" -print;)  

temp_path="temp_path.txt" 
 
if [ -f $temp_path ]; then  
    rm -r $temp_path  
fi  
  
for dir in ${dir_arr[*]}  
do  
    find $dir -type f >> $temp_path  
done  
  
for file in $(awk -F '/' '{print $NF}' $temp_path  | sort | uniq -d)  
do  
    echo $file  
done


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章