Reputation: 533
I'm not sure this is possible, but I'm trying to replace a character from standard output on the fly.
The issue is like this. A command c1 produces the output
So, c1 | less
gives me ABC
I would like to replace occurrences of B
with D
, so I get ADC
.
If possible that my command chain should be something like
c1 | <something> | less
and print ADC
instead of ABC
.
Upvotes: 1
Views: 2204
Reputation: 1325
use sed:
c1 | sed 's/B/D/' |less
For the given example of replacing "ABC" with "ADC". If you want to replace all occurrences of B on D use the option g (global)
sed 's/B/D/g'
You can find more using:
man sed
Upvotes: 3