LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-10-2007, 04:40 PM   #1
vxc69
Member
 
Registered: Jul 2004
Distribution: Ubuntu
Posts: 387

Rep: Reputation: 33
Deleting files particular type of file using rm?


Hello,

Let's say I have 3 .sh files in a dir and a whole lot of files that are named like this:
index.html.1
index.html.2
index.html.3 ... and so on. How would I delete all of the html files? rm *.html won't work because of the number at the end. I know I could just move the 3 shell scripts out of there and delete the rest but I'm curious if there is another way without moving files. Anyone know?




Thanks,
vxc

p.s: If you think I can't do this with a single command and a shell script might work, I'll move this thread to the programming forum.
 
Old 05-10-2007, 04:46 PM   #2
Gillingham
LQ Newbie
 
Registered: Oct 2006
Distribution: Debian and Suse
Posts: 1

Rep: Reputation: 0
try:

Code:
rm *html*
This should do the trick provided the string "html" does not appear in any of the names of the files you don't want removed.
 
Old 05-10-2007, 04:47 PM   #3
vxc69
Member
 
Registered: Jul 2004
Distribution: Ubuntu
Posts: 387

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by Gillingham
try:

Code:
rm *html*
This should do the trick provided the string "html" does not appear in any of the names of the files you don't want removed.
Yup, that's exactly what I was looking for. Thanks!!
 
Old 05-11-2007, 09:47 PM   #4
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
OR
Code:
rm index*
Providing the word "index" is not the 'first' word of any file,s name you do not want removed. If so, you can lengthen it to:
Code:
rm index.html*

Last edited by Junior Hacker; 05-11-2007 at 09:49 PM.
 
  


Reply

Tags
delete, file, name, same, specific



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting files after x days from the latest date file sriramsreedhars Programming 8 03-03-2007 09:30 AM
Deleting files rossi46 Mandriva 5 11-08-2006 08:15 AM
JPG Files problem unknow file type Riktov Linux - Newbie 2 11-07-2006 04:55 PM
Changing File Permission in a FTP directory to prevent deleting of files shawnbishop Linux - Software 3 01-10-2006 05:41 AM
deleting files by type? dr_zayus69 Linux - Newbie 2 12-01-2004 07:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:41 AM.

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
Open Source Consulting | Domain Registration