LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 01-10-2007, 11:25 PM   #1
dhaus111
LQ Newbie
 
Registered: Feb 2006
Posts: 26

Rep: Reputation: 15
recursive find


I'm trying to use the command line to remove all m3u files from my MP3 folders using find or locate. The idea was to use rm > find *.m3u but god (google) seems to make me believe that find has no recursive option. Do I need a script to do this seemingly simple task? Do I need to use locate instead? And if so... How do I configure locate to index my other mounted media (2 NTFS drives, 1 ReiserFS drive)

I'm using Ubuntu Edgy AMD64.

I think I'm going to go look at some porn now to get the frustration out...
 
Old 01-11-2007, 12:03 AM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,238

Rep: Reputation: 121Reputation: 121
This should work. I found it in the man pages for xargs. It also covers the case where filenames/directories contain embedded spaces.
Code:
find /top_level_directory -name *.m3u -type f -print0 | xargs -0 /bin/rm -f
 
Old 01-11-2007, 12:24 AM   #3
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
If you think about it, a recursive option doesn't make much sense given that find will automatically look below the specified dirctory
 
Old 01-11-2007, 12:25 AM   #4
dhaus111
LQ Newbie
 
Registered: Feb 2006
Posts: 26

Original Poster
Rep: Reputation: 15
That worked...Thanks very much

I don't understand what the hell xargs does, or why
rm > find /top_level_directory -name *.m3u -type f -print0
wouldn't work however?
 
Old 01-11-2007, 12:28 AM   #5
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Wouldn't you at least need the > the other way?
 
Old 01-11-2007, 12:29 AM   #6
dhaus111
LQ Newbie
 
Registered: Feb 2006
Posts: 26

Original Poster
Rep: Reputation: 15
when i use find from my home directory (find . *VTC*)
it doesn't find a file that is contained in a dir called "A+" that is located in my home dir. It spits out a bunch of output that show paths that are contained in my home dir, and i've even seen the file I was looking for in that output, but no results are found?
 
Old 01-11-2007, 12:37 AM   #7
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Isn't the syntax

find . -name *VTC*

?
 
Old 01-11-2007, 12:39 AM   #8
dhaus111
LQ Newbie
 
Registered: Feb 2006
Posts: 26

Original Poster
Rep: Reputation: 15
shit, you're right
so i tried this
rm < find /home/haus/Reading/ -name *VTC* -type f
rm: invalid option -- n
Try `rm --help' for more information.


I got the m3u thing done, I'm just trying to understand and experiment at this point.
 
Old 01-11-2007, 12:41 AM   #9
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Try it without the rm < and see where -- n is coming from
 
Old 01-11-2007, 12:45 AM   #10
dhaus111
LQ Newbie
 
Registered: Feb 2006
Posts: 26

Original Poster
Rep: Reputation: 15
haus@outremer:~$ find /home/haus/Reading/ -name *VTC* -type f
/home/haus/Reading/A+/VTC - CompTIA A+ Certification.zip
haus@outremer:~$


i see...
I guess it would be from the spaces without the proper \ in front of them...?
 
Old 01-11-2007, 12:59 AM   #11
dhaus111
LQ Newbie
 
Registered: Feb 2006
Posts: 26

Original Poster
Rep: Reputation: 15
Well, The -print0 switch doesn't help the command in the form that I was curios about getting working. I guess xargs is the only way to go. I still am curious though on how to have updatedb also index my other HD's. I greatly appreciate the help guys. may much pleasant debauchery find you all.
 
  


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
Recursive, comm, find, PDFs zamdrist Linux - General 3 11-13-2006 10:56 PM
Recursive Copy fizgig10 Linux - Newbie 1 07-16-2005 11:58 PM
Recursive Query JMagana Linux - Software 1 12-01-2004 07:46 PM
rm -r what is recursive wogga Linux - Software 3 05-28-2004 02:29 PM
call recursive find except on ./foo/ Hano Linux - General 1 07-30-2002 01:08 PM


All times are GMT -5. The time now is 12:16 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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration