Linux pipelines

I recently had a Subversion working copy with several files that were modified because they should not have been under source control to begin with.  I had to find all the modified *.Plo files and remove the folders that contained them.  I ended up using this, which is the longest pipeline I can remember using:

svn st|grep '^M.*Plo$'|awk '{print $2}'|xargs -n 1 dirname|uniq|xargs svn rm --force

To break it down:

  1. svn st: List all local changes
  2. grep ‘^M.*Plo$’: Find modified *.Plo files
  3. awk ‘{print $2}’: Strip off the “M” (modified) flag
  4. xargs -n 1 dirname: Find the directory name of each file
  5. uniq: Remove duplicates
  6. xargs svn rm –force: Remove the folders

Since the folders containing the *.Plo files were all named .deps, I could’ve accomplished the same thing with this, but I didn’t think of it until after:

find -name .deps|xargs svn rm --force

Anyway, yay pipelines!

Post a Comment

Your email is never shared. Required fields are marked *

*
*