Reputation: 15399
I am using grep to find out all occurences of a VB function call. I give the command this way -
grep -n "FunctionX" FormX.frm
1814: FunctionX
2682: FunctionX
3020:' FunctionX
3292:Private Sub FunctionX()
3333:On Error GoTo FunctionX_Err
3388: ' GoTo FunctionX_Exit
3394:GoTo FunctionX_Exit
3456:FunctionX_Err:
3460:FunctionX_Exit:
But as you can see, it also gave me instances where it was not a function call. For a VB function call, the function name is not followed by anything, so I assumed that it's a function call followed by whitespace. I tried -
grep -nr "FunctionX[[:space:]]" FormX.frm
However, this gave me no results. Is this because "\n" is not considered to be whitespace? Every call to FunctionX in the code is followed by a "\n". If so, how do I get the desired result? Please help me out. Thanks.
Upvotes: 1
Views: 1045
Reputation: 301015
Try matching on the end of line
grep -nr 'FunctionX[[:space:]]*$' FormX.frm
Remember grep is looking at the input line-by-line, so it's not going to be seeing the carriage returns. The pattern above finds any line that ends with FunctionX with some possible (real) whitespace following it before the end-of-line.
Upvotes: 1