Richard Rublev Richard Rublev - 1 year ago 43
Linux Question

Why is grep not finding integer*2?

For example

grep -n 'integer*2' *.f

Shows nothing.But

grep -n '*2' *.f

main.f:57: integer*2 itime(nxmax)
main.f:605: dxy=((xsource(is)-xobs)**2+(ysource(is)-yobs)**2)**.5
main.f:622: chisum=chisum+diff2/uobs**2
model.f:15: integer*2 veli(nxmax)
model.f:52: size2=size**2
time.f:151: integer*2 itime(nxmax)

I really do not understand this.

Answer Source

* is an operator, meaning "match the previous term 0 or more times". So integer*2 matches


none of which appear in your program. * at the beginning of an RE is meaningless (there's no previous term), so is either ignored or treated as match for a *. Escape the `* to have it match an actual star: