The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Lots of questions about linux. Methal Red Hat 1 04-25-2008 11:06 AM
Deleting Files bc4 UNIX for Dummies Questions & Answers 1 01-25-2007 11:27 PM
Deleting files BG_JrAdmin SUN Solaris 1 11-29-2006 01:17 AM
Lots of file copyingand renaming? AeroEngy UNIX for Dummies Questions & Answers 12 08-03-2005 09:59 PM
Deleting the files livetaurean19 Shell Programming and Scripting 0 06-16-2005 04:16 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-25-2006
B14speedfreak B14speedfreak is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 55
Question Deleting lots of files.....

Hi All,

Thanks in advance for reading and any posts...

I have to delete a lot of files (about 6 pages of a4 (ls -ltr)) but I have to keep some as well. I would normally do an rm * to get rid of them all, but thats not what I want to do. Is there anyway I could rm * but add in a list of files that I don't want to delete.

Thanks for reading and any posts,

Mark.
  #2 (permalink)  
Old 05-25-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
put a list of "keeper files" into goodfiles then
Code:
ls -1 | grep -v -f goodfiles | \
while read file
do
       rm -f $file
done
  #3 (permalink)  
Old 05-25-2006
B14speedfreak B14speedfreak is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 55
Talking

Thanks for the replay will try making a small shell script with it... thanks Mark...
  #4 (permalink)  
Old 05-25-2006
B14speedfreak B14speedfreak is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 55
Lightbulb

When I run that I get the following error:

grep: illegal option -- f
Usage: grep -hblcnsviw pattern file . . .
[2] + Done(2) ls -1 | grep -v -f goodfiles | \;while read filee

Any ideas????

Thanks again,

B14...aka... marky mark....
  #5 (permalink)  
Old 05-25-2006
madhunk madhunk is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 91
Check if your grep supports -v and -f options...

type
Code:
man grep
at the command prompt

If you are on Sun Solaris box, some options are supported by

Code:
/usr/xpg4/bin/grep
and some options are supported by

Code:
/usr/bin/grep
Give the entire path of grep...

See if it works!!
  #6 (permalink)  
Old 06-07-2006
B14speedfreak B14speedfreak is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 55
Thumbs up

yeah it works but under solaris you need to use /usr/xpg4/bin/grep in order to get it to work....

...sorry for the slow response had a few other things that took priotry...

Thanks again,

B14... aka... marky mark
  #7 (permalink)  
Old 06-07-2006
B14speedfreak B14speedfreak is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 55
Lightbulb

Come across a possibly simpiler way (un specified way), you can do the following if you want delete old files:

HTML Code:
find [path] -mtime +[integer] -exec rm {} \;
This essentially will allow you delete all files in a directory over a certain age, not sure if this is of interest to anyone but it will sort out my problem, I am guessing that you could do something similar with the above as well so that you can delete a pile of files
Sponsored Links
Closed Thread

Bookmarks

Tags
mtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0