LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-22-2008, 11:27 AM   #1
visitnag
Member
 
Registered: Mar 2008
Posts: 147

Rep: Reputation: 15
removing only few files at a stroke...


Dear all..

I have some waste files and some useful files in a directory. I want to remove waste files in a single stroke not useful files. Suppose the useful files start with a letter p and all other files are waste files. I dont want to mv the useful files into other directory. I want to do this job with rm command only and with a single stroke.
 
Old 09-22-2008, 11:34 AM   #2
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
$ rm `locate /path/to/directory/p` (The `s are backticks, upper left of keyboard.)
 
Old 09-22-2008, 11:50 AM   #3
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Wait! That would delete all files that start with 'p' instead of the ones that don't start with a 'p'.

And, if that's what you wanted to do, the easier syntax would be rm -f p* (assuming your working directory is the one containing the files starting with 'p').

For the problem as stated, try locate -r $(pwd)/[^p]* | rm -f or some other file listing command piped through grep -v [^p].*
 
  


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
Key stroke problem satimis Fedora 0 06-19-2007 12:17 PM
Black stroke at the right of my desktop Deelk Fedora 2 04-09-2006 02:52 PM
Removing files wihtout removing containing Direcotry caps_phisto Linux - General 2 10-07-2004 08:16 AM
How do i adjust key stroke speed,10.0? akihandyman Mandriva 1 07-17-2004 06:16 PM
Key Stroke Logger MrTheGeek Linux - Security 1 02-03-2002 01:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:13 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