Skip to content

Instantly share code, notes, and snippets.

@hitherejoe
Created April 9, 2015 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitherejoe/ac371e2db005cf271e01 to your computer and use it in GitHub Desktop.
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/
#! /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