Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Find misplaced log files in my music library:
- find . -type d -name "*" | while read dir; do list=$(ls -1 "${dir}" 2>/dev/null); n=$(echo "${list}" | wc -l | tr -d "[:space:]"); log=$(echo "${list}" | grep ".log$"); if [[ $n -lt 4 && ! -z $log ]]; then echo "${log} in ${dir}"; fi; done
- Find empty directories:
- find . -type d -name "*" | while read dir; do n=$(ls -1 "${dir}" 2>/dev/null | wc -l); if [[ $n -eq 0 ]]; then echo "${dir}"; fi; done
- Compare log files:
- find . -name "*.log" | while read log; do md5sum -b "$log" | cut -d'*' -f1; done | sort > ~/Desktop/md5sum_library.txt
- find . -name "*.log" | while read log; do md5sum -b "$log" | cut -d'*' -f1; done | sort > ~/Desktop/md5sum_diff.txt
- cat md5sum_diff.txt | while read md5; do grep "$md5" md5sum_library.txt && echo "$md5" >> md5sum_remove.txt; done
- find . -name "*.log" | while read log; do md5=$(md5sum -b "$log" | cut -d'*' -f1 | tr -d "[:space:]"); grep "$md5" ~/Desktop/md5sum_remove.txt && rm "$log"; done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement