Tim Van Wassenhove home

For a couple of days now i’ve been pondering about posting something about my love for GNU text-utilities but never got round to it. A couple of minutes ago i read Phil Windley’s Using Grep and Find post so here is a one-liner that shows how you can add a reference to a msbuild target file to all csproj files in a given folder:

find -name *.csproj -exec sed -i -e '#^</project>$# <import Project="X:\\BuildTasks\\Corp.targets" />\r\n</project>' {} \;

Or if you are frustrated with System.Diagnostics.CodeAnalysis.SuppressMessageAttributes and want to remove them from all your cs files:

find -name \*.cs -exed sed -r -i -e 's#\[.\*?SuppressMessage.*?\]##' {} \";