Linux: Dump contents of all files matching certain filename

I had to look for a specific line of code across multiple branches of a project. There were over 30 or so branches, so it'd be terribly time consuming to look through them all one by one.

Instead of doing that, write up a little snippet that'll dump all the contents of those files into vim.

find -name "your_filename.py" -exec echo '-----' {} '-----' \; -exec cat {} \; | vim -

This will search any folder under the current working directory for "your_filename.py" and dump its contents into vim.

The contents of the files are seperated by "----- path/to/your_filename.py -----" for easy searching.

[ Source ]

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog