The SED command can perform line matching well, but precisely match certain content from a line, you can use the grep command and the-O and-e options to achieve this purpose. -O indicates "only-matching", that is, "only matching. It is not enough to use it alone. It is very powerful to use extended regular expressions with the-e option.
For example, the following text tmp.txt contains:
{"Aid": 45, "path": "attachment/mon_1112/2_00005728040df3ab346.jpg "}
If we want to obtain the aid value 45, we can do the following first:
Grep-o-e 'aid ": [1-9] * 'tmp.txt
The result is as follows:
Aid ": 45
In this case, we can use the-F option of awk to indicate the colon separator, so that it is easy to filter out the value of 45. The overall command is as follows:
Grep-o-e 'aid ": [1-9] * 'tmp.txt | awk-F: '{print $2 }'
Use the-O and-e options of grep to exact match the regular expression.