Hi I have been trying to execute a code where i used a variable $logs to save all my linux logs.
Now i want to grep the variable for a pattern and print the whole line for the lines that have the pattern in them.
I want to print whole line where i do grep /pattern/ and the lines that have pattern in them have to be printed.
Anyways here is my code.
my $logs = $ssh->exec("cat system_logs");
my $search = "pattern";
if(grep($search,$logs))
{
# this is where i want to print the lines matched.
# I want to print the whole line what command to use?
}
any help is greatly appreciated.
Try this: