Created
April 9, 2015 10:42
-
-
Save hitherejoe/ac371e2db005cf271e01 to your computer and use it in GitHub Desktop.
Modify directory contents based on a collection of existing files http://hitherejoe.com/wordpress/using-bash-modify-directory-contents-based-existing-files/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
path="./current/"; | |
assets="./assets/"; | |
files=( "$path"* ) | |
files=( "${files[@]##*/}" ) | |
for dir in $assets*; do | |
for file in "$dir"/*; do | |
filename="${file##*/}" | |
if ! [[ ${files[*]} =~ "$filename" ]]; then | |
rm $file | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment