Skip to content

Instantly share code, notes, and snippets.

@Komosa
Created October 13, 2017 08:57
Show Gist options
  • Save Komosa/d7805f5fff0e926a36ccd82d0e203ca4 to your computer and use it in GitHub Desktop.
Save Komosa/d7805f5fff0e926a36ccd82d0e203ca4 to your computer and use it in GitHub Desktop.
nice awk trick
#!/bin/bash
# remove files not in arrar 'files_to_keep'
find -type f -name '*.bin' \
| awk -v keep=" ${files_to_keep[*]} " -e 'keep !~ " "$0" "' \
| xargs -L1 -I II sh -c 'git rm -f II 2>/dev/null || rm II'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment