Today I Learned
I needed find all the draft blog posts I had. My draft blog posts were mixed in with real blog posts, and after not looking at the blog for a while I did not remember what posts I had started.
With a bash command I can search for all files recursively that contain “draft: true”. THis gives me all my drafts, and I don’t have to worry about losing them or keeping them in a separate place.
How to
grep -rl "draft: true"
How it works:
grep
: Searches for substrings and filters contents-rl
r
: Searches recursivelyl
: Return file name assiciated with the match
Excluding Files
If you’re getting some files you don’t want, you can add exclusion criteria. For example if you add | grep -v ".ipynb_checkpoints"
to the end, it will exclude notebook checkpoints that you almost certainly don’t want to see!