Moe Notes 简体中文

Terminal field notes

Find files, locate a line of text, and see what changed using three standard commands.

Read the notes
Example terminal session (excerpt)
$ grep -Fn 'draft' notes.md
4:Leave the draft for Monday.

$ diff -u notes.old.md notes.md
-Review the draft on Friday.
+Leave the draft for Monday.

Working with text files

Find Markdown files

Run this from the directory where you want to start. The dot means the current directory. The quotes let find apply the filename pattern to each file.

find . -type f -name '*.md'

Match a line of text

In notes.md, look for the literal text draft. The -n flag includes the line number. Add -i to ignore case.

grep -Fn 'draft' notes.md

Compare two versions

Put the older file first. In the change block, lines that start with - were removed and lines that start with + were added. The command leaves both files untouched.

diff -u notes.old.md notes.md