[colug-432] scripting question

Matthew Hyclak hyclak at gmail.com
Sat May 7 22:40:15 EDT 2016


You could do this a couple of ways:

rm -v `ls -R | grep "\ 2\.mp3"`

ls -R | grep "\ 2\.mp3" | xargs rm -v

You could also look into using find instead of the ls and grep combination
and use the -exec argument to call rm -v

Lots of ways to skin that cat.

Matt
On May 7, 2016 22:32, "Johnathon Scott" <js573712 at ohio.edu> wrote:

> Hi all,
>
> I am having difficulty understanding how to pass values to rm.  I want
> to delete files that match a specific criterion.  I recently acquired an
> os x machine and iTunes has doubled a significant portion of my
> library.  But fortunately, the duplicates are easy to identify, they all
> look like "foo 2.(mp3|m4a)".
>
> What I have right now is "ls -R | grep "\ 2\.mp3" | rm -v".
>
> Thank you for your time,
>
> Johnathon Scott
>
> --
>
> Personal Site: https://www.pergraphicum.net
>
>
>
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20160507/8b53ee47/attachment.html 


More information about the colug-432 mailing list