LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-08-2007, 11:06 PM   #1
mmnnv
LQ Newbie
 
Registered: Dec 2006
Posts: 11

Rep: Reputation: 0
ls and rm together


is there any way to use ls and rm together? maybe a pipeline?

i'm working on a vfat mounted drive and i want to remove all JPEG images and some OSX file from every directory..

Code:
./base
    .DS_Store
    file.mp3
    ./dir1
        ._.DS_Store
        file.jpg
        file.mp3
    ./dir2
        .DS_Store
        .FBCIndex
        /.FBCLockFolder
            .FBCSemaphoreFile
        ._.DS_Store
        file.mp3
and i want to end up with:
Code:
./base
    file.mp3
    ./dir1
        file.mp3
    ./dir2
        file.mp3
if anyone knows how to use "rm -rf" with "ls -R" or knows of a shell script that will do this for me, please let me know.
 
Old 04-08-2007, 11:14 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,047

Rep: Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915
This comes up all the time. Try "find" instead with either "exec or "xargs".
The manpage for find even has an example to do almost what you asked for.
 
Old 04-08-2007, 11:23 PM   #3
mmnnv
LQ Newbie
 
Registered: Dec 2006
Posts: 11

Original Poster
Rep: Reputation: 0
thanks! i used 'find -name ".*DS_Store" -exec rm {} \;' and *.jpg and it worked great.
 
  


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




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