LinuxQuestions.org
Have you heard the LinuxQuestions.org Podcast?
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This 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

Tags used in this thread
Popular LQ Tags , , , , ,

Reply
 
Thread Tools
Old 05-10-2007, 05:40 PM   #1
vxc69
Member
 
Registered: Jul 2004
Distribution: Ubuntu
Posts: 340
Thanked: 0
Deleting files particular type of file using rm?


[Log in to get rid of this advertisement]
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.
vxc69 is offline  
Tag This Post , , , , ,
Reply With Quote
Old 05-10-2007, 05:46 PM   #2
Gillingham
LQ Newbie
 
Registered: Oct 2006
Distribution: Debian and Suse
Posts: 1
Thanked: 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.
Gillingham is offline     Reply With Quote
Old 05-10-2007, 05:47 PM   #3
vxc69
Member
 
Registered: Jul 2004
Distribution: Ubuntu
Posts: 340
Thanked: 0

Original Poster
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!!
vxc69 is offline     Reply With Quote
Old 05-11-2007, 10:47 PM   #4
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687
Thanked: 21
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 10:49 PM..
Junior Hacker is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
Deleting files after x days from the latest date file sriramsreedhars Programming 8 03-03-2007 10:30 AM
Deleting files rossi46 Mandriva 5 11-08-2006 09:15 AM
JPG Files problem unknow file type Riktov Linux - Newbie 2 11-07-2006 05:55 PM
Changing File Permission in a FTP directory to prevent deleting of files shawnbishop Linux - Software 3 01-10-2006 06:41 AM
deleting files by type? dr_zayus69 Linux - Newbie 2 12-01-2004 08:56 PM


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

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration