Reply
Thread Tools
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#51
Okay, I'll give it a try. Thanks!

Oh, and what if I want to gag multiple outputs such as
llib pianobar | grep -v "|>" "(i) Receiving new playlist... Ok."?

I don't know how to add a second filter to that grep command, and yes, I looked online for about 30 minutes on this already and couldn't find it.
 
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#52
This almost worked.

llib pianobar | grep -v "|>"

Instead of gagging just those two character symbols, it mutes out the entire line all together.

Is there a better way to use that grep command?
 

The Following User Says Thank You to Addison For This Useful Post:
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#53
Okay. At least this a good start.

llib pianobar | grep -v "(i) Receiving new playlist... Ok."

Now it only shows the songs that have played making the output in Xterm a little less messy.

All I would like is to also get rid of all the "|> " and """ characters as well if this is possible.

Thanks Andy.
 

The Following User Says Thank You to Addison For This Useful Post:
Posts: 78 | Thanked: 109 times | Joined on Jan 2012 @ Washington State
#54
Originally Posted by Addison View Post
All I would like is to also get rid of all the "|> " and """ characters as well if this is possible.
Yes, grep is line oriented. To rewrite parts of lines, we use "sed" instead:

command | sed 's/|>//' > outfile.txt

Would remove the first "|>" sequence it found in each line. If you want to remove *all* such, it's 's/|>//g' (g suffix to sed substitute command).

sed can also remove whole lines:

command | sed '/foobar/d'

Matches line with "foobar" within them and deletes them. I point this out because sed can run with a whole list of rules (provided by a file) and thus can probably do all your folding, spindling, and mutilating with a single "sed" command. If the file cleanup.sed had the two lines:

/Receiving/d
s/|>//g

Then running it with:

command | sed -f cleanup.sed > output.txt

Would both trim off lines with "Receiving" as well as remove the character sequence |> (without otherwise changing the line).

Andy
 

The Following 2 Users Say Thank You to vandys For This Useful Post:
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#55
I'm confused.

This seems to kind of work....

PATH=$PATH:/usr/local/bin
llib pianobar | sed 's/|> //'

That's 2 spaces after /> and not just 1.

The thing is it won't display the song now until after it has finished playing.

No big deal I guess.

Anyway, can you help me pipe all of these exceptions together?

llib pianobar | sed 's/|> //' | sed 's/ "//' | grep -v "(i) Receiving new playlist... Ok." | grep -v "Station"

If I try and do more than one filter, Xterm just hangs without doing anything.

I'm not sure what I'm doing wrong on this.

Cheers.
 

The Following User Says Thank You to Addison For This Useful Post:
Posts: 78 | Thanked: 109 times | Joined on Jan 2012 @ Washington State
#56
Originally Posted by Addison View Post
The thing is it won't display the song now until after it has finished playing.
That's I/O buffering for you. See if your sed takes the "-u" switch to act unbuffered.

Andy
 

The Following 2 Users Say Thank You to vandys For This Useful Post:
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#57
Dang it I'm super dumb.

llib pianobar | sed -u 's/|> //'
sed: invalid option -- u

llib pianobar | sed 'u/|> //'
sed: unsupported command u

llib pianobar | sed '/|> //u'
sed: unsupported command /

How do you use the -u option?
 

The Following User Says Thank You to Addison For This Useful Post:
Posts: 78 | Thanked: 109 times | Joined on Jan 2012 @ Washington State
#58
Originally Posted by Addison View Post
Dang it I'm super dumb.

llib pianobar | sed -u 's/|> //'
sed: invalid option -- u
No, you're not dumb at all. You just have the default "sed" from the mini-linux environment, Busybox. I just grabbed the latest GNU source for a full sed and built it for the n810. Grab it from:

www.vsta.org/andy/pickup/n810_sed

Probably you shouldn't scribble on top of the Busybox one, just put this one in /usr/local/bin/sed (or /usr/local/bin/gsed to be really defensive) and it definitely has the -u option.

Andy
 

The Following 2 Users Say Thank You to vandys For This Useful Post:
Addison's Avatar
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#59
Thanks!

Okay, once last thing, how do I string these all together?

llib pianobar -u | sed 's/|> //' | sed -u 's/ "//' | grep -v "(i) Receiving new playlist... Ok." | grep -v "Station"

Am I using the pipe command correctly?
 

The Following User Says Thank You to Addison For This Useful Post:
Posts: 78 | Thanked: 109 times | Joined on Jan 2012 @ Washington State
#60
Originally Posted by Addison View Post
Thanks!

Okay, once last thing, how do I string these all together?

llib pianobar -u | sed 's/|> //' | sed -u 's/ "//' | grep -v "(i) Receiving new playlist... Ok." | grep -v "Station"

Am I using the pipe command correctly?
It's a little needless. Easier would be to put these four lines:

s/|> //
s/"//g
/Receiving new playlist/d
/Station/d

In one file, say "filter.sed". Then run pianobar as:
llib pianobar | sed -u -f filter.sed

I don't think pianobar looks at its command line arguments, so I left off that -u you had put for pianobar.

Andy
 

The Following 2 Users Say Thank You to vandys For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 15:07.