One of people's dissatisfaction with shell commands in UNIX systems is that their form does not always prompt their functions. For example, to identify the grep function of Unix commands, you can only learn about them in advance, or depending on people's ingenuity and familiarity with the Unix editor ed. The literal form of this command is useless for Unix beginners.
In the Unix editor Ed, the command/regular_expression/is used to search for substrings that match the regular expression.
Put g in front of this command, and it becomes a global command, which indicates that the search scope is the entire file being edited.
If P is added after this command, all the lines in the file containing matched substrings are printed.
Therefore, the command g/regular_expression/P can be abbreviated as grep. It indicates that all rows in the file containing the substring matching the regular expression are printed.
From the principle of programming language, translated by Robert W. sebesta, translated by Zhang Qin and Wang fangmoment, Mechanical Industry Press, pp. 2008, 9th.