LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ls and rm together (https://www.linuxquestions.org/questions/linux-newbie-8/ls-and-rm-together-544416/)

mmnnv 04-08-2007 10:06 PM

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.

syg00 04-08-2007 10:14 PM

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.

mmnnv 04-08-2007 10:23 PM

thanks! i used 'find -name ".*DS_Store" -exec rm {} \;' and *.jpg and it worked great.


All times are GMT -5. The time now is 10:55 AM.