Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9234729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:51:29+00:00 2026-06-18T06:51:29+00:00

I want to write a little progress bar using a bash script. To generate

  • 0

I want to write a little progress bar using a bash script.

To generate the progress bar I have to extract the progress from a log file.

The content of such a file (here run.log) looks like this:

Time to finish 2d 15h, 42.5% completed, time steps left 231856

I’m now intersted to isolate the 42.5%. The problem is now that the length of this digit is variable as well as the position of the number (e.g. ‘time to finish’ might content only one number like 23h or 59min).

I tried it over the position via

echo "$(tail -1 run.log | awk '{print $6}'| sed -e 's/[%]//g')"

which fails for short ‘Time to finish’ as well as via the %-sign

echo "$(tail -1 run.log | egrep -o '[0-9][0-9].[0-9]%')"

Here is works only for digits >= 10%.

Any solution for a more variable nuumber extraction?

======================================================

Update: Here is now the full script for the progress bar:

#!/bin/bash

# extract % complete from run.log
perc="$(tail -1 run.log | grep -o '[^ ]*%')"

# convert perc to int
pint="${perc/.*}"

# number of # to plot
nums="$(echo "$pint /2" | bc)"

# output
echo -e ""
echo -e "   completed: $perc"
echo -ne "   "
for i in $(seq $nums); do echo -n '#'; done
echo -e ""
echo -e "  |----.----|----.----|----.----|----.----|----.----|"
echo -e "  0%       20%       40%       60%       80%       100%"
echo -e ""
tail -1 run.log
echo -e ""

Thanks for your help, guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:51:30+00:00Added an answer on June 18, 2026 at 6:51 am

    based on your example

    grep -o '[^ ]*%'
    

    should give what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a little function to generate samples from appropriate distributions, something
I want to write a little program in C to extract the PE (Entry
I have a little test.sh script that I run from the command line ./test.sh
I am currently trying to write a little powershell script (I have no experience
I want to write a little script for managing a bunch of files I
I want to write a little iOS video client and have to use HTTP
I want to write a little DBQuery function in perl so I can have
I have SBCL running on a Ubuntu machine. I want to write a little
I am stating to write a little PC tool to read log files using
I want write a little code analyzer which parses nested structures and translates into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.