I am trying to print out a specific string within a line with sed.
The first problem is that I have some difficulties finding a string which contains slashes, I already tried some solutions provided in other threads but was unsuccessful, hopefully someone can help me.
I have a file called output.log.
An example of a line is:
013-11-08 19:45:52 evtlog.bad PROD/INSE/6004113 2012-11-08 19:04:06 /test11/golf/TierTwo/2013-11/evtlog.log
So with sed I want to print out only below string from this line:
/test11/golf/TierTwo/2013-11/evtlog.log
And I want to find the string in this line with: "golf/TierTwo/2013-11"
So I would use for example:
sed 'golf/TierTwo/2013-11' output.log
And get an output of:
/test11/golf/TierTwo/2013-11/evtlog.log
How can I achieve this?
If there would be a better solution instead of sed, it would be welcome also. My goal is to use this in a script, either bash or perl
sed
or if you just want to solve the problem? Because every problem that can be solved withsed
can and will also be solved withawk
orperl
. If you don't care it is better to rewrite your question so it is more general.