keepcalculator

06 Numbers and Powers

Bash If Else Statement: Usage and Examples

Card No. 06·52250 · Updated · Standard formula, shown below

Pace (min/km) 3.00 min/km
Speed (km/h)
20.00 km/h
Result
Time (min)
30 min
You entered
You enter
Time (min)
You get
Pace (min/km), Speed (km/h)
Rounding
2 dp

Use if statements in bash to run commands only when a condition is true, and else to run a fallback when it is false. You type if [ condition ]; then ... else ... fi, where the condition is a command or test expression that returns a zero (success) or non-zero (failure) exit status. This article explains the syntax, common test operators, and practical examples so you can write reliable conditional logic in your shell scripts.

Formula

The calculator above works out your running pace and speed for a given time over 10 km. The formula is:

  • Pace (min/km) = Total time (min) / Distance (km)
  • Speed (km/h) = Distance (km) / (Total time (min) / 60)

Variables: t = total time in minutes, d = distance in km (fixed at 10). Pace is the number of minutes it takes to cover one kilometre; speed is the number of kilometres you cover in one hour.

Worked Example

Using the default values: t = 30 min, d = 10 km.

  1. Pace = 30 / 10 = 3.0 min/km
  2. Speed = 10 / (30 / 60) = 10 / 0.5 = 20.0 km/h

The calculator returns pace = 3.00 min/km and speed = 20.00 km/h.

When to Use This Calculator

Use this tool when you have a training time and want to know your average pace or speed for a 10 km run. It is handy for planning workouts, checking if you hit a target pace, or comparing different training days. The same formula applies to any distance if you change the fixed value.

How to Read the Result

A lower pace (min/km) means faster running. A higher speed (km/h) also means faster. The two are inversely related: if pace goes down, speed goes up. For example, a pace of 4.5 min/km equals a speed of about 13.3 km/h. Use the unit that matches your training plan or GPS watch.

Common Mistakes

  • Mixing units: if you enter time in hours instead of minutes, the pace will be wrong. Convert hours to minutes first (1 h = 60 min).
  • Forgetting that pace is per kilometre, not per mile. If your distance is in miles, convert to km (1 mile ≈ 1.609 km) before using the formula.
  • Rounding too early: round only the final answer, not intermediate steps, to keep accuracy.

Limits of the Formula

This is a simple average calculation. It does not account for hills, wind, stops, or changes in speed during the run. It gives the average pace and speed over the whole distance, not your instantaneous pace at any moment. For interval training or varied terrain, you need a GPS device or a more detailed analysis.

Frequently Asked Questions

How do I convert my pace from min/km to min/mile?

Multiply the pace in min/km by 1.609 to get min/mile. For example, 5:00 min/km is about 8:03 per mile. Conversely, divide min/mile by 1.609 to get min/km.

What is a good 10 km pace for a beginner?

There is no single answer, as it depends on age, fitness, and training. A common beginner pace is around 6:30–7:30 min/km (about 8–9.2 km/h). Focus on finishing comfortably first, then gradually speed up.

Can I use this calculator for other distances?

Yes, the formula works for any distance. Just change the distance value in the formula (replace 10 with your distance in km) and recalculate. The calculator here is fixed to 10 km, but you can do the math manually for other distances.

Why does the speed show a different number than my watch?

Watches often show current speed or moving average, which excludes stops. This calculator gives the overall average speed including all time. If you stopped for water or traffic, your watch’s moving average will be higher.

How do I set a target pace for a race?

Decide on a realistic goal time, then divide by the distance. For a 10 km race in 50 minutes, your target pace is 5:00 min/km. Use this calculator to check what speed that corresponds to, and practice running at that pace.

Related

Formula used
in t | Time (min) | min | 30 | 0 | 1440
out pace | Pace (min/km) | min/km | t / 10 | 2
out speed | Speed (km/h) | km/h | 10 / (t / 60) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →