BASH: How to remove all files except those named in a manifest?
Posted
by brice
on Stack Overflow
See other posts from Stack Overflow
or by brice
Published on 2010-05-06T16:12:06Z
Indexed on
2010/05/06
16:18 UTC
Read the original article
Hit count: 254
I have a manifest file which is just a list of newline separated filenames. How can I remove all files that are not named in the manifest from a folder?
I've tried to build a find ./ ! -name "filename"
command dynamically:
command="find ./ ! -name \"MANIFEST\" "
for line in `cat MANIFEST`; do
command=${command}"! -name \"${line}\" "
done
command=${command} -exec echo {} \;
$command
But the files remain.
[Note:] I know this uses echo. I want to check what my command does before using it.
© Stack Overflow or respective owner