Results 1 to 7 of 7
Hi
I'm trying to use sed to change the title of my xterm, from the output of mplayer. I have put together the following expression:
Code:
echo "ICY Info: StreamTitle='Artist ...
- 10-19-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 9
question about sed
Hi
I'm trying to use sed to change the title of my xterm, from the output of mplayer. I have put together the following expression:
(The echo and sleep stuff is just for testing)Code:echo "ICY Info: StreamTitle='Artist - Song Title';StreamUrl='';" | sed "s/StreamTitle='\([^']*\)/\0\e]0;\1\a/" ;sleep 10
For some reason this doesn't work -- The output is :
which makes me think that \e isn't interpreted as an escape-character by sed.Code:ICY Info: StreamTitle='Artist - Song Titlee]0;Artist - Song Title';StreamUrl='';
Any ideas?
- 10-20-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Not sure what you're trying, to extract the artist and the songtitle from the line you can try this:
RegardsCode:awk -F "'" '{print $2}'
- 10-20-2007 #3Just Joined!
- Join Date
- Oct 2007
- Posts
- 9
I'm trying to pass everything through untouched, but when I have a match for the song-title, I want additionally print \033[0;SONG_TITLE\007 (Where SONG_TITLE is the song title match). In xterm, this escape-sequence will change the title of the console-window.
I still want the normal output, so everything should pass through untouched -- I just want the escape-sequence in there as an addition to the output.
- 10-20-2007 #4Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi. troelskn.
For the sed short-coming on \e et al, you may want to consider using perl:
cheers, drlCode:ESCAPE SEQUENCES These work as in normal strings. \a Alarm (beep) \e Escape \f Formfeed \n Newline -- excerpt from man perlrerefWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 10-20-2007 #5Just Joined!
- Join Date
- Oct 2007
- Posts
- 9
Thanks, but I wanted to use sed -- mostly as a learning exercise. Now, if this is in fact a limitation of sed -- that it's simply impossible to do -- then I'll use Perl for the task, but I just have a hard time accepting that sed can't do what I want it to.
- 10-20-2007 #6Just Joined!
- Join Date
- Oct 2007
- Posts
- 9
I figured it out! Instead of using \e, I tried with \x1B, which generates an escape character. I thought I already tried that, but I had used \x33, which is wrong (33 is the same character in octal).
Thanks for your help none the less
- 10-20-2007 #7Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
Good, glad you got it.
Whilst you were doing that, I was looking at info sed, and found:
I dislike looking at info, but man sed and even O'Reilly sed & awk didn't discuss the character sequences (at least not that I could find) ... cheers, drlCode:`\dXXX' Produces or matches a character whose decimal ASCII value is XXX. `\oXXX' Produces or matches a character whose octal ASCII value is XXX. `\xXX' Produces or matches a character whose hexadecimal ASCII value is XX. -- excerpt from info sedWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote