LinuxQuestions.org
Help answer threads with 0 replies.
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 04-07-2005, 11:46 AM   #1
GUIPenguin
Member
 
Registered: Aug 2004
Location: Maine
Distribution: Gentoo Linux
Posts: 239

Rep: Reputation: 30
Help with shell script


OK basicly we have a bunch of users in there own sub directorys in /home

People have been saving there .mp3 files and it is not ok on the server we have setup for school work.

I am trying to write a shell script that would use find /home to go through the home directorys.

I really need some help.
This is what I thought

I was thinking of using grep and save a VAR from a grep

Code:
find /home > mp3log

VAR=`cat mp3log | grep .mp3`

rm $VAR
but this would only provide 1 delete for 1 file.

EDIT: I figured it out and made it alot easer for my self this is what I did and it works great
Code:
find /home -depth -type f -name '*mp3' -exec rm {} \;

Last edited by GUIPenguin; 04-07-2005 at 12:01 PM.
 
Old 04-07-2005, 12:10 PM   #2
skunkburner
Member
 
Registered: Mar 2004
Distribution: Fedora Core 17 & 18, Debian Wheezy
Posts: 137

Rep: Reputation: 16
how about

rm -r *.mp3
 
Old 04-07-2005, 12:19 PM   #3
GUIPenguin
Member
 
Registered: Aug 2004
Location: Maine
Distribution: Gentoo Linux
Posts: 239

Original Poster
Rep: Reputation: 30
no thanks....

but this is really wierd if anyone can answer me this.
When I run the script where ever it removes mp3 files it will leave a blank file called newestone which is VERY wierd ??? this only happens when I run it on my fedora core 2 box but not on my gentoo box ???

Last edited by GUIPenguin; 04-07-2005 at 02:09 PM.
 
Old 04-08-2005, 09:06 AM   #4
Oliv'
Senior Member
 
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014

Rep: Reputation: 36
Hello,

Quote:
I figured it out and made it alot easer for my self this is what I did and it works great

code:

find /home -depth -type f -name '*mp3' -exec rm {} \;
just a tip, I think you should use -iname instead of -name. 'cause if someone download a mp3 with .MP3 extension, it won't be deleted.
Another problem is that some users may understand the trick and rename their mp3 files into .txt or something like that file... or convert their mp3 into ogg...
about your other problem... sorry no idea
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM

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

All times are GMT -5. The time now is 03:38 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration