cciollaro
cciollaro

Reputation: 374

how to filter a phrase (ends in newline) from terminal output

So I'm running my specs and there's an annoying error message that interpolates itself into the output. I don't want to fix the problem that's causing the error message. I just think it would be nice to filter it out using sed or awk or something.

Let's say the error message is this:

I'm an annoying error message that ends in a newline.

And so my experience is something like this:

$ rspec
....f....*.....I'm an annoying error message that ends in a newline.
............................................................I'm an annoying error message that ends in a newline.
....................................................

Whereas the ideal experience would be:

$ rspec | sed something
....f....*....................................................................................................

I've gotten pretty far by doing this:

$ rspec | sed 's/I'"'"'m an annoying error message that ends in a newline.//'

but it leaves a newline everywhere the message would have been. And for some reason tacking on \n makes it stop matching.

Thanks for reading!

Upvotes: 0

Views: 59

Answers (1)

Zombo
Zombo

Reputation: 1

awk 1 RS='zulu\n' ORS=

Input

alpha bravo charlie
delta echo zulu
foxtrot golf hotel
india juliet zulu
kilo lima mike

Output

alpha bravo charlie
delta echo foxtrot golf hotel
india juliet kilo lima mike

Upvotes: 1

Related Questions