LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-03-2010, 02:47 PM   #1
heropage
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Rep: Reputation: 0
help with bash remove files script


I am trying to remove all the files except like [number].mpg in my folder.
my folder have files like this
1234.mpg
3535.mpg
abce.mpg
abc123.mpg
3245.mpg
....

I want to all the files which is not a number. In this example, I want to remove
abce.mpg
abc123.mpg

I can not figure out a bash script to remove.
Please help
 
Old 11-03-2010, 03:11 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You can list the files you want to delete with *[0-9].mpg, for example echo *[0-9].mpg
 
Old 11-04-2010, 08:23 AM   #3
heropage
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
You can list the files you want to delete with *[0-9].mpg, for example echo *[0-9].mpg
Thanks for the reply
I can use
ls *[0-9].mpg
to list the files.
But how to remove the file which is not *[0-9].mpg

I am new to bash.
 
  


Reply



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
Bash script to remove files older than 3 days rust8y Linux - General 26 10-04-2012 08:26 AM
bash script to remove first characters from every line (00) Linux - General 8 08-01-2011 10:28 AM
Bash script to find and remove similar lines from multiple files linuxquestion1 Programming 9 07-13-2011 01:45 AM
help with bash script: remove * to the last . in string drkstr Linux - Software 3 04-25-2006 04:54 PM
remove part of string in bash script crewblunts Programming 2 03-16-2006 05:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:57 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
Open Source Consulting | Domain Registration