Skip to content

Instantly share code, notes, and snippets.

@shortland
Created May 17, 2020 17:16
Show Gist options
  • Select an option

  • Save shortland/fa7f2566414ce6a34263217831329daa to your computer and use it in GitHub Desktop.

Select an option

Save shortland/fa7f2566414ce6a34263217831329daa to your computer and use it in GitHub Desktop.
Bash 1 liner script to remove duplicate files that appear in specified directories
# Change the dir to remove duplicate files from - and the directory to read from
cd dirToRemoveDupesFrom && for f in *.c ; do find ../dirToCheckIfFileExistsAlready -name $f -exec rm $f \; ; done"
# Makefile equivalent
bash -c "cd $(RMD) && for f in *.c ; do find $(SRCD) -name \$$f -exec rm \$$f \; ; done"
@shortland
Copy link
Author

It looks for duplicate files that have the file extension .c, just change that to your needs~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment