maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   Your Favorite Apps/Mods NOT In Repositories (https://talk.maemo.org/showthread.php?t=86041)

Addison 2013-02-19 00:47

Re: Your Favorite Apps/Mods NOT In Repositories
 
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 2013-02-19 01:13

Re: Your Favorite Apps/Mods NOT In Repositories
 
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?

Addison 2013-02-19 01:22

Re: Your Favorite Apps/Mods NOT In Repositories
 
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. :)

vandys 2013-02-19 17:12

Re: Your Favorite Apps/Mods NOT In Repositories
 
Quote:

Originally Posted by Addison (Post 1323745)
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

Addison 2013-02-19 19:56

Re: Your Favorite Apps/Mods NOT In Repositories
 
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. :)

vandys 2013-02-19 20:08

Re: Your Favorite Apps/Mods NOT In Repositories
 
Quote:

Originally Posted by Addison (Post 1323901)
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

Addison 2013-02-19 20:17

Re: Your Favorite Apps/Mods NOT In Repositories
 
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?

vandys 2013-02-20 00:24

Re: Your Favorite Apps/Mods NOT In Repositories
 
Quote:

Originally Posted by Addison (Post 1323912)
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

Addison 2013-02-20 00:28

Re: Your Favorite Apps/Mods NOT In Repositories
 
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?

vandys 2013-02-20 01:33

Re: Your Favorite Apps/Mods NOT In Repositories
 
Quote:

Originally Posted by Addison (Post 1323960)
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


All times are GMT. The time now is 19:18.

vBulletin® Version 3.8.8