I'm looking through a couple hundred files looking for the following string:
$v1=Name($v2[x1].$v3[x2].$v4[x3].$*v5[x4].)
grep -HREln "(x1)" . > foo
find . -type f | xargs grep -l 'x1' > foo
However the variable x1 changes from file to file. What I would like to do is search for the pattern:
$*=Name($*[*].$*[*].$*[*].$**[*].)
regardless of the variable or white spaces. any assistance would be great.
Change every *
to .*
, put \\
before every $
, [
, ]
, or literal .
, and you're there!
find . -type f |
xargs grep -l 'Name(\$.*\[.*\]\.\$.*\[.*\]\.\$.*\[.*\]\.\$.*\[.*\]\.)' > foo
Note: this will miss variations that span multiple lines, and does not take whitespace into account at all.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.