Issue
I need to run the script grep the logfile and then show the log file. I have tried the following command sh abc.sh | grep "Log File: "| sed -e s/'Log File (.*)$')
I got an error as: sed expression #1 unterminated s' command
Solution
The syntax of your sed
command is invalid. It's not entirely clear to me what you are trying to do with that invalid sed
, but I think you're looking for:
sh abc.sh | sed -n -e '/Log File:/s///p'
This will suppress all output except those lines which match the regex Log File:
, and the text Log File:
will be replaced with the empty string. (s///p
will use the previous pattern for the match, and replace the first occurrence of that pattern with the empty string. The p
flag causes the line to be printed.)
Answered By - William Pursell Answer Checked By - Gilberto Lyons (WPSolving Admin)