pnovotnak
pnovotnak

Reputation: 4581

BASH, cat Buffer

cat report.txt | sed 's/<\/li>/<\/li> \n/g' > report.txt

This obviously results in an empty file.

Is there a mechanism that allows you to store the data before processing it or store the output until the command has finished executing and then write the file?

http://en.wikipedia.org/wiki/Pipeline_(Unix)#Implementation:

"...a receiving program may only be able to accept 100 bytes per second, but no data is lost. Instead, the output of the sending program is held in a queue. When the receiving program is ready to read data, the operating system sends its data from the queue, then removes that data from the queue."

Sounds like there should be a simple trick to load this into a queue instead of writing it immediately to file, then unload it after the command has finished?

Thanks much!

Upvotes: 1

Views: 757

Answers (1)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340763

What you need is editing in place:

sed -i 's/<\/li>/<\/li> \n/g' report.txt 

Upvotes: 2

Related Questions