January 8th, 2014, 06:32 AM
SED command issue
I'm facing a issue with my SED command where I need to extract a value from a grep command output. I'm able to extract the value, just that the initial character which i need is not getting extracted.
I pipe the ps and grep command and on output one of line is
Command: ps -ef|grep web-ELISA
This has my application log location.
To extract the exact log location i need to extract the following text alone.
so i use I used sed command with pipe option
command: ps -ef | grep web-ELISA | ps -ef|grep -E web-EY | sed -n "s/.*\(.*apps.*logs\).*/\1/p"
I'm getting the response as
The initial character which I need is '/' which is not comming as expected. Even i tried following command with *\apps instead of \apps
command: ps -ef | grep web-ELISA | ps -ef|grep -E web-EY | sed -n "s/.*\(.*\apps.*logs\).*/\1/p"
January 8th, 2014, 06:34 AM
Even if we have solution to concatenate '/' to the return response and doing a chage directory[cd] command is also fine.
Originally Posted by ramkumar.siva
January 8th, 2014, 02:14 PM
You seem to be getting your / and \ all mixed up.
That / is also the command separator for the s command isn't helping.
Fortunately, you can replace the command separator with another char of your choice.
sed -n "s@.*\(/apps.*logs/\).*@\1@p"
January 9th, 2014, 05:35 AM