- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Simulating a graph-bar generator
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2004 01:34 AM
03-29-2004 01:34 AM
Any smart shell-script to simulate into a text environment a graph-bar chart. Pls imagine the following data colection:
A=8
B=2
C=5
D=0
E=4
Then I'll need obtain something like this:
====
====
====
==== ====
==== ==== ====
==== ==== ====
==== ==== ==== ====
==== ==== ==== ====
A B C D E
Best regards,
JMM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2004 01:44 AM
03-29-2004 01:44 AM
Re: Simulating a graph-bar generator
BR,
JMM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2004 01:57 AM
03-29-2004 01:57 AM
Re: Simulating a graph-bar generator
#!/usr/bin/sh
A=8
B=2
C=5
D=0
E=5
STRING="====="
for LIST in A B C D E
do
COUNT=0
echo "$LIST \c"
while [ $COUNT -lt $LIST ]
do
echo "$STRING \c"
COUNT=`expr $COUNT + 1`
done
echo ""
done
This generates
A ===== ===== ===== ===== ===== ===== ===== =====
B ===== =====
C ===== ===== ===== ===== =====
D
E ===== ===== ===== ===== =====
Hope that's of some use.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2004 02:08 AM
03-29-2004 02:08 AM
Re: Simulating a graph-bar generator
in perl:
$data{"A"} = 8;
$data{"B"} = 2;
$data{"C"} = 5;
$data{"D"} = 0;
$data{"E"} = 4;
foreach $key (keys %data) { $max = $data{$key} if ($data{$key} > $max)};
while ($max-- > 0) {
foreach $key (keys %data) {
printf ("%6.6s ", ($data{$key} >= $max)? "====": " ");
}
print "\n";
}
foreach $key (keys %data) {
printf ("%6.6s ", $key);
}
print "\n";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2004 02:17 AM
03-29-2004 02:17 AM
SolutionWith boundary condition fixed, and sorted key values:
$data{"A"} = 8;
$data{"B"} = 2;
$data{"C"} = 5;
$data{"D"} = 0;
$data{"E"} = 4;
foreach $key (sort keys %data) {
$max = $data{$key} if ($data{$key} > $max);
push @k, $key;
};
while ($max > 0) {
foreach $key (@k) {
printf ("%6.6s ", ($data{$key} >= $max)? "====": " ");
}
print "\n";
$max--;
}
foreach $key (@k) {
printf ("%6.6s ", $key);
}
print "\n";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2004 02:18 AM
03-29-2004 02:18 AM
Re: Simulating a graph-bar generator
- tput and cups : I have a script wich use this kind of stuff. It's rather slow actually.
- use the C standard library curses.h
If you're successfull, send a feedback on the forum :-D
Good luck.
Nicolas