I started downloading a big file in the background using

$ nohup wget http://example.tld/big.iso &

which also gives me a nohup.out file that includes the output of wget.

Now, if I later want to watch the downloading process, I could use $ tail -f nohup.out but that fills up my terminal window faster than I'd wish for. What I'd like to see is the last line constantly updating (just like when using wget alone).

I tried $ tail -n 1 -f nohup.out but it seems to affect only the initial tailin'.

Generally speaking, if it is possible to limit (in this case to 1) the number of lines a command's output has available/visible it would solve this problem. Sort of having the output in a Circular buffer — just think of the normal progress bar $ wget example.tld/big.iso would print.

Is there such a solution?

Or am I climbing the tree wrong way? (Meaning, would it be easier to limit nohup's output or do something else?)

4 Answers 4


If you do not want to limit the scrolling region (see my other answer), you can also use the carriage return to go back to the beginning of the line before printing the next line. There is an escape sequence that clears the rest of the line, which is necessary when the current line is shorter than the previous line.

nohup wget http://cdimage.debian.org/debian-cd/6.0.3/amd64/iso-dvd/debian-6.0.3-amd64-DVD-1.iso &
el="$(tput el)"; # Clear to the end of the line
tail -n 1 -f nohup.out | while read -r line; do echo -n $'\r'"$el$line"; done;

You can use watch here:

watch -n 0.5 -e "tail -n 1 nohup.out"

Edit: The -e (alias --exec) option looks suitable here. Especially if you aim at running watch with very small intervals, this reduces the overhead caused by running sh -c internally by watch in each cycle.

  • 2
    Note that this spawns a new tail process every second, which might or might not be something you care about. Also, be sure to specify a sub-second interval (e.g. watch -n 0.1) to simulate the "constantly updating" part. (This obviously increases the number of processes and file open calls, too.) Finally, if you are using OS X, you can get watch from MacPorts, as it is not available by default.
    – janmoesen
    Oct 21, 2011 at 7:10
  • This is a bit workaroundish, but great as such. I was expecting non-fullscreen answer, so that I would see previous outputs — but really I could use watch in a new terminal window. I also found out that using tail -n 2 is more useful than -n 1 with wget, at least with watch interval of 1 second, because otherwise the latest percentage might not be seen; this isn't a flaw in your answer, but I mentioned it if someone else decides to watch wgets tailed nohup output. Oct 21, 2011 at 9:09
  • @janmoesen For this specific scenario, having a new tail process probably isn't too much overkill; but as a general answer this is good to take into account. I also noted that watch -n 0.1 didn't work, but watch -n 0,1 worked — there might be locales applied, though I haven't seen locales applied to terminal command options before. As a side note: brew install watch worked great as well :-) Oct 21, 2011 at 9:18
  • A side note: Whether watch will work with 0,1 or 0.1 depends on your locale settings (it uses the decimal symbol defined for your locale). Check LC_ALL=C watch -n 0.1 "date +%S.%N". Oct 21, 2011 at 10:11

There are certain Xterm control sequences you can use to limit the lines of your terminal that are scrolled. Look for "Set Scrolling Region". It's a bit of a kludge, though. Be sure to reset your terminal afterwards:

nohup wget http://cdimage.debian.org/debian-cd/6.0.3/amd64/iso-dvd/debian-6.0.3-amd64-DVD-1.iso &
clear; echo -n $'\e[1;2r'; tail -f nohup.out | grep --line-buffered .
# The "grep" line is to ensure a single line; you can also use "awk 1" or "sed" etc.
  • <Insert the usual note about non-portability here>
    – janmoesen
    Oct 20, 2011 at 20:28
  • This is another great alternative, but one that's also best used in dedicated window as the tail -f still fills the buffer and also because terminal needs reset afterwards anyway. This isn't as inline as I hoped, but otherwise it might be what I sought for. Oct 21, 2011 at 9:33

If you don't want the output to occupy the whole current terminal window, you can use a simple while loop:

while true; do 
  XXX=$( tail -n1 my.log )
  echo -en " \r$XXX\r"
  sleep 0.5
done; echo
  • 1
    Notice that to able to scroll the terminal output while any output-producing command is running, you need to edit your terminal emulator settings and disable scrollTtyOutput (or similar) option. Oct 21, 2011 at 10:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .