Skip to content

Instantly share code, notes, and snippets.

@1f0
Created December 31, 2018 03:47
Show Gist options
  • Save 1f0/961cf11fedd7ad4ae63cf3868ded7dd9 to your computer and use it in GitHub Desktop.
Save 1f0/961cf11fedd7ad4ae63cf3868ded7dd9 to your computer and use it in GitHub Desktop.
rm not match files
sed -e 's,^,^,' -e 's,$,$,' filelist > newfilelist
cd your_directory
ls | egrep -vf newfilelist | xargs -n 1 echo rm > rmscript
#If the files have spaces in their name (if the files have the " in the name that will not works) :
ls | egrep -vf newfilelist | sed 's,^\(.*\)$,rm "\1",' > rmscript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment