This question already has an answer here:
- Can I make `cut` change a file in place? 6 answers
I am trying to run a command in bash where I have a
command 1 which accepts a large amount content through stdin and then outputs that content to a
command 1 generates a stream of content and apparently
file.txt gets created as soon as
command 1 starts and then gets updated once
command 1 finishes with the correct output.
echo 'a lot of content' | command 1 > file.txt
The problem is that I only want to create or touch
command 1 is completely finished.
Is there any way to achieve that?
Use-case: I am using a web development server that gets refreshed every time a file changes, so I am doing some pre-processing before really updating the file.
The problem with the above command is that if the file is updated or create with empty content the server refreshes instantly, having an empty page, so I really wanted to wait for the post processing to finish (let's say it takes about 4 seconds) and only then touch
file.txt so it is correctly rendered on the page.
So there's only one command I need to run here, which is
command 1 and then, after
file.txt is updated, my web development server will refresh automatically.