LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-20-2011, 04:44 AM   #1
1Volt
LQ Newbie
 
Registered: Jun 2011
Posts: 13

Rep: Reputation: Disabled
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
 
Old 06-20-2011, 04:52 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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.
 
1 members found this post helpful.
Old 06-20-2011, 05:06 AM   #3
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 7,564

Rep: Reputation: 696Reputation: 696Reputation: 696Reputation: 696Reputation: 696Reputation: 696
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.
 
1 members found this post helpful.
Old 06-20-2011, 05:15 AM   #4
1Volt
LQ Newbie
 
Registered: Jun 2011
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by colucix View Post
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 it Works Thank u for ur time . ^_^

Thanks anyway guys ~!

Last edited by 1Volt; 06-20-2011 at 05:16 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Extremely slow to move files to trash and/or delete files permanently... CT_0000 Linux - Newbie 2 01-09-2014 11:06 AM
[SOLVED] Delete regular files (not hidden files) with find + rm in one line older than 15 Virtuose Linux - Newbie 1 01-08-2011 06:24 PM
need to rsync only selected files (--files-from) also need to delete files on dest. ? BrianK Linux - General 5 10-22-2009 10:52 PM
Can I delete files in /mnt/tmp? and Files in the trash can will not delete? M$ISBS Slackware 15 10-03-2009 12:56 AM
Script help - delete files older than 45 days but exclude the system files jojothedogboy Linux - Software 3 06-13-2008 04:43 PM


All times are GMT -5. The time now is 06:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration