0

I'm writing a Bash script that makes a series of build commands visiting each of subdirectories. It mainly prints the logs from the build command, but it occasionally prints logs by itself, like what directories it'll make build commands or where it is now.

The problem is because the logs from build commands are often so long and fast, I can barely notice the log messages from the script itself.

So I'd like to restrict the logs from build commands within a few lines at the bottom of the current terminal, so that I can see the messages on my terminal like this;

Building 'example-project-1'..       # Message from my script
# Logs from the build command scroll up within the following window.
------------------------------------------------------------------------------
clang -c source1.c -o source1.o
clang -c source2.c -o source2.o
ar -rc example-project-1.a *.o 
------------------------------------------------------------------------------
Building 'example-project-2'..
------------------------------------------------------------------------------
clang -c source1.c -o source1.o
clang -c source2.c -o source2.o
ar -rc example-project-2.a *.o 
------------------------------------------------------------------------------
Build completed.

But I have no idea how to reuse some terminal lines with Bash. Can I implement this (sort of) feature in Bash?

  • 1
    Possibly by running the build commands in a separate pane in tmux? – Kusalananda Feb 22 at 8:53
  • You can use \r as linebreak to overwrite the current line. A better approach might be to use curses – Panki Feb 22 at 10:44

Your Answer

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

Browse other questions tagged or ask your own question.