Re: Extract Text with "sed"



On Tue, 29 Jan 2008 05:54:38 -0800 (PST), Meendar <meendar@xxxxxxxxx> wrote:
Giorgos Keramidas wrote:
On Tue, 29 Jan 2008 00:08:15 -0800 (PST), Meendar <meendar@xxxxxxxxx> wrote:
I am having a text generated from version output of an executable as

$ myprogram -v
Version: Myprogram/1.2.1 - Centos
Built: Aug 8 2007 13:05:44

I need to extract 1.2.1 from the above output, however i used sed like

$ myprogram -v | sed -e '/s/Myprogram\ /(*) ^-

$ ( echo 'Version: Myprogram/1.2.1 - Centos' ; \
echo foo ) | \
sed -n -e '1s/.*\/\(.*\) - .*/\1/p'
1.2.1

Thanks for the answer, however i couldn't get the actual while i go
with executable.

Just replace the myprogram with httpd and please answer me. It looks
same as myprogram version No

$ httpd -v | sed -n -e '1s/.*\/\(.*\) - .*/\1/p'

There are at least a couple of reasons why this may be happening:

(1) The `httpd' writes to stderr, instead of stdout.

(2) The version line is not the first.

Can you try the variation shown below?

% httpd -v 2>&1 | sed -n -e '/Version:/ s/.*\/\(.*\) - .*/\1/p'

If this doesn't work either, it may be useful to see the output of
something like:

% httpd -v 2>&1 | od -c

.



Relevant Pages

  • Re: Extract Text with "sed"
    ... Just replace the myprogram with httpd and please answer me. ... writing to stdout, and you can expect the data to go to the ... If, however, the second is the one that discards the ...
    (comp.unix.programmer)
  • Re: Extract Text with "sed"
    ... Just replace the myprogram with httpd and please answer me. ... That's because the sed expression is either misformatted by the program ...
    (comp.unix.programmer)
  • Re: Extract Text with "sed"
    ... Just replace the myprogram with httpd and please answer me. ... Giorgos Keramidas wrote: ...
    (comp.unix.programmer)
  • Re: Extract Text with "sed"
    ... Meendar ... | Version: Myprogram/1.2.1 - Centos ... | I need to extract 1.2.1 from the above output, ...
    (comp.unix.programmer)