I will be writing a shell script to go through the log file generated by my application , I need to separate out only function names and minimum info about the call from the logs generated.
Log file format will be –
0.0003 636488 +440 -> include_once(/var/www/public/const.php) /var/www/public/ajax_shop.php:2
Now, out of such line I want to extract that – “include_once” was called at line “2” from the file “ajax_shop.php”
how should I use regular expression in shell script for this situation ?
One way using sed:
\([^(]*\) => This matches till a closing bracket is encountered. [^(]* => Means a series of characters which is not a ‘(‘.
Using awk:
awk uses multiple delimiters >,( and :. Using this, it becomes simple just to print the 2nd field and the last field.