LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Delete All Files With * Except some Files ? (https://www.linuxquestions.org/questions/linux-newbie-8/delete-all-files-with-%2A-except-some-files-887281/)

1Volt 06-20-2011 03:44 AM

Delete All Files With * Except some Files ?
 
Hello ,
i want to know how to delete files with * command but with except some files like:

\tmp\
i have there 100 file let's say 100 jpg picture
i can do this rm *.jpg to remove all files
but i don't want to delete picture 10 , 19 , 47
i can do that in one line ??
lol don't tell me to do like this (rm 00*.jpg {delete 001-009.jpg} ) then .... till finish lol


please help i really need this command for project ^_^
and srry for bad english

colucix 06-20-2011 03:52 AM

What about the find command excluding the three files?
Code:

find . ! \( -name 010.jpg -o -name 019.jpg -o -name 047.jpg \) -delete
First try it without the -delete option. If the three files are excluded from the list, you can run again with -delete.

business_kid 06-20-2011 04:06 AM

man rm will show you 'rm -i'
Asking on a forum about your project will generally be seen as avoiding the work that your lecturers intended you to do. We can solve that problem, but we won't be there at exam time.

1Volt 06-20-2011 04:15 AM

Quote:

Originally Posted by colucix (Post 4390542)
What about the find command excluding the three files?
Code:

find . ! \( -name 010.jpg -o -name 019.jpg -o -name 047.jpg \) -delete
First try it without the -delete option. If the three files are excluded from the list, you can run again with -delete.

OMG :D it Works Thank u for ur time . ^_^

Thanks anyway guys ~!


All times are GMT -5. The time now is 01:52 AM.