Feed on
Posts
Comments

say you’ve got a stream of filenames that you’d like to remove.  for instance, i’ve got a bunch of filenames that pop out of this command:

grep -v “,” `search “boot0.txt”` | sed ‘s/boot.*//’

turns out i can’t directly pipe this to rm.  instead, i’ve got to use the xargs command, as so:

grep -v “,” `search “boot0.txt”` | sed ‘s/boot.*//’ | xargs rm -r


Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

8 Responses to “pipe filenames to rm in unix”

  1. on 04 Mar 2009 at 3:54 pm Anton Thorn

    Priceless! Thank you! :)

  2. on 21 Jun 2009 at 11:37 am Donald Kail

    Awesome!

  3. on 16 Sep 2009 at 5:28 pm danips

    Thanks it worked :)
    BTW nice blog header ^_^

  4. on 21 Nov 2009 at 10:59 am ikenna

    thanks mate!

  5. on 05 Feb 2010 at 10:37 pm Anonymous

    great command

  6. on 01 Feb 2011 at 4:15 pm Elia

    very nice menu!!!!

  7. on 23 Aug 2011 at 5:17 pm Me

    Worked great!!!

  8. on 02 Nov 2011 at 2:12 pm Åsmund Stavdahl

    Awesome tip and even more awesome header :D

Did I get this wrong? Let me know!

Trackback URI | Comments RSS

More blogs about http://desk.stinkpot.org:8080/tricks.