Find and Move Conflicted Files With Bash
Cloud-sync and version-control tools often leave duplicate files labelled conflicted. The command below collects them into a temporary directory for manual review.
Command
find . -type f -name '*conflicted*' -print0 | while IFS= read -r -d '' file; do
mv "$file" /tmp/conflicted-files/
done
Explanation
find . -type f -name '*conflicted*'limits results to regular files.-print0and theread -d ''loop handle paths with spaces.- Files are moved into
/tmp/conflicted-files/so they can be inspected or deleted safely.
Safety Tips
- Create the destination directory first:
mkdir -p /tmp/conflicted-files. - Replace
mvwithechowhile testing to avoid moving unintended files. - On production servers, run the command under a non-root account and capture a backup before bulk operations.