| [ << Documentation work ] | [Top][Contents] | [ Website work >> ] |
| [ < Working on subsections ] | [ Up: Tips for writing documentation ] | [ Scripts to ease documentation work > ] |
5.6.2 Searching
If you are working with the git repository, the most useful tool
on the command line to search text is git grep, which
recursively scans the repository’s files for strings using
regular expressions (regex). This manual cannot give an
introduction into the use of regular expressions; there are plenty
of resources in the internet that may help you.
Files not managed by git in a repository (for example, all files
generated during compilation or building the documentation) cannot
be searched with git grep, though. In such cases you
might use the standard grep tool instead, which has
almost exactly the same syntax.
Another limitation of both grep and git grep
is their inability to search a string across multiple
lines,9
which would be extremely helpful in finding arguments of Texinfo
commands. A solution is to use a variant of grep called
pcregrep (or its newer version pcre2grep –
the acronym PCRE stands for Perl Compatible Regular Expressions).
You most likely have to install this program; look for packages
called ‘pcre-tools’, ‘pcre2-tools’, or something similar.
As an example, let’s assume that you want to find all occurrences
of @rweb{Easier editing} within
Documentation/en/. After changing to this directory, a
search with
git grep '@rweb{Easier\s*editing}'
might return the following.
usage/external.itely:editors are listed in @rweb{Easier editing}.
usage/external.itely:are listed in @rweb{Easier editing}.
[The string \s* means to search for whitespace (\s)
zero or more times in succession (*).]
On the other hand, a search with
pcregrep -r -M '@rweb{Easier\s*editing}' .
shows one more hit.
./learning/installing.itely:For more information, see @rweb{Easier
editing}.
./usage/external.itely:editors are listed in @rweb{Easier editing}.
./usage/external.itely:are listed in @rweb{Easier editing}.
[Option -r enables recursive searching of the current directory (‘.’), option -M activates multi-line searching.]
Footnotes
(9)
There is limited support for multi-line searching
with recent versions of standard grep. However, it
cannot display context around the matches for technical reasons.
| [ << Documentation work ] | [Top][Contents] | [ Website work >> ] |
| [ < Working on subsections ] | [ Up: Tips for writing documentation ] | [ Scripts to ease documentation work > ] |