Search code examples
linuxbashshellnohup

How to get nohup + tail to NOT add newlines to carriage returns?


I use the Keras package, which offers a nice "progress bar" feature to stdout when you're training. As it updates the bar, it uses carriage returns with no newlines so that the bar stays on the same line (at the bottom of the terminal) as it gets longer and longer.

But when I run via nohup myprogram &, and I try to follow the run using tail -f nohup.out, it adds newlines to every carriage return, so I end up seeing an extremely long output of every state of every progress bar on hundreds of new lines, instead of just having each bar take up one line: i.e. nohup or tail is adding newlines to the carriage returns (CRs).

How I can disable this, so that CRs remain just CRs?

I couldn't find any relevant parameters in the man pages for nohup or tail. Wondering if this has to do with the difference between running in an interactive shell vs. ...whatever state nohup uses. Tried searching on this, found several SO posts about adding newlines to CRs, but none about not adding them.

I'm on Ubuntu 16.04, running bash.


Solution

  • Neither nohup nor tail do that. They just don't.

    Many programs will vary their output depending on whether it goes to a terminal or not. Maybe the application you are using does this too.