I have the following code:
int val
nameof_function();
above code is in this file filename.txt I try to find that sequence of lines in a file using
grep "int val.*\n.*(" filename.txt
but it is not working with multiple line.
I have also tried
awk '/int val/,/\(/' filename.txt
Here i am not getting file name in output
If I am using grep
I can find file name in output but not ble to search muliple line
I need an output that looks like this:
filename.txt:int val nameof_function
Please any one help me
pcregrep
with the-M
switch - however if that's not an option, see Searching match of multi-line regex in files (without pcregrep). You can access the current filename inawk
using theFILENAME
builtin variable. – steeldriver Jan 30 '20 at 13:00int val
statement is not terminated with a;
for example. – AdminBee Jan 30 '20 at 13:01