how to create a bash script that creates a bar graph in the terminal window
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to create a bash script that creates a bar graph in the terminal window
Hey, I just want to know how you would go about making a bash script that creates a bar graph in the terminal window. This is a real time bar graph of cpu load average times that updates at a specified interval. I know you use the uptime command but not completely sure how to go about making the bar graph. Any help would be appreciated, thanks.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Rep:
bar makes a progress bar. gnuplot may have such functionality. In any event, you're probably looking for a ncurses-based program, if that helps narrow the search.
Well, if that page is from the actual course, then clues have been provided about how to achieve this goal.
"Linux commands which display the load average include uptime, w, top and xload"
...
"Hints: besides viewing the man pages for uptime, w, top and xload you may want to investigate"
the stty command
the setterm command
how to print unicode characters in a Linux terminal
Well, if that page is from the actual course, then clues have been provided about how to achieve this goal.
"Linux commands which display the load average include uptime, w, top and xload"
...
"Hints: besides viewing the man pages for uptime, w, top and xload you may want to investigate"
the stty command
the setterm command
how to print unicode characters in a Linux terminal
labs 7 and 8 of course
how to use 256 colour terminals
unicode table
Please let us know.
I understand that you use the uptime,w,top commands for the data for load averages, but what I wanted to know was how exactly would you go about creating the bar graph in the terminal while the script is running. Just the base of the actual graph, everything else I can do because he gave us hints where to look. For example would you use a loop to create the horizontal lines,vertical lines and scale on the side?
"For this assignment you will design and code a new BASH command (script) named "cload". The purpose of "cload" is to display a colourful bar graph, in a terminal window, of the three Linux load averages in "real" time. The three load averages are the 1 minute average, the 5 minute average and the 15 minute average."
It does NOT say you have to create the bar graph in bash, it says "display a colourful bar graph, in a terminal window".
I know what it looks like he's asking. There are variables I am not aware of, sorry.
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495
Rep:
Quote:
Originally Posted by Satsugyo
I wanted to know was how exactly would you go about creating the bar graph in the terminal while the script is running.
Not sure I understand your question. You want the graph to be updated in real time? You'd need to draw the graph inside a loop, so that each time the loop would be redrawn and the commands to get the load average would be called again. You're drawing the graph with a loop, then you'd have a nested loop.
Otherwise, make it more clear with specific details what you're asking.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.