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
3292:Private Sub FunctionX()
3333:On Error GoTo FunctionX_Err
3388: ' GoTo 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.
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.