0

I have a program that writes to the standard output. It does not write all info at once, it does computation and then writes new bits. The output of the program is being stored in a file.

$ ./theprogram.sh > results.csv

While the script was running I copied results.csv to peek at numbers. After that, next copies of the file show no changes even though some records should be added there. What happened to the original file after I copied during writing? Are new records being discarded?

  • Did you modify or replace results.csv at all? – goldilocks Feb 19 '14 at 16:48
  • No, what I did is cp results.csv results_copy.csv – ashim Feb 19 '14 at 17:10
3

Use,

tail -f results.csv to watch file whilst it grows you can break out of tail with Ctrl-C

less works too command G takes you to last line F will follow.

piping through tee eg. ./theprogram.sh | tee results.csv allows you to watch output on stdout and log to file simultaneously.

Your copy shouldn't have affected anything. However you are running a script, could there possibly be something in that script that would expect exclusive access to the output file and abort if it doesn't get it ? Personally I doubt it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.