Replace `uniq` with `awk` for removing duplicates
Check if paths exist before using them; fix #1