Re: Extract Text with "sed"
- From: Giorgos Keramidas <keramida@xxxxxxxxxxxxxxx>
- Date: Thu, 31 Jan 2008 12:03:14 +0200
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
.
- References:
- Extract Text with "sed"
- From: Meendar
- Re: Extract Text with "sed"
- From: Giorgos Keramidas
- Re: Extract Text with "sed"
- From: Meendar
- Extract Text with "sed"
- Prev by Date: Re: Getting user input in Linux?
- Next by Date: Re: using libjpeg
- Previous by thread: Re: Extract Text with "sed"
- Next by thread: Re: Extract Text with "sed"
- Index(es):
Relevant Pages
|
|