![]() ![]() ![]() The second grep matches the words: any sequence of one or more non-space characters and wc -l counts the lines of output. *?) otherwise, something like _bold_ not bold _bold_ would be just one match. I used the Perl regex engine ( -P) to enable non-greedy matching (. This looks for anything between two pairs of _. Now, to count bold words, we can use grep -Po '_.*?_' infile.md | grep -o ']\+' | wc -l No "funny stuff" like (inline) code with these characters, or escaped _ or *, or lists with leading * that throw our count off.Bold uses _, italic uses * (even though it might also be ** and _).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |