Linux Command Line

Find and recursively grep through files

Can be done with find -exec or find | xargs with various tradeoffs.

Example, search through all python files and show results with line number and filename.

find -name \*.py -exec grep -Hn "search terms" {} \;

rsync

No trailing slash - copy directory

rsync -avz /foo/bar /baz

copies directory bar to /baz/bar

Trailing slash - copy directory contents

rsync -avz /foo/bar/ /baz

copies contents of /foo/bar to /baz without creating bar directory.