<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Bash Shell Scripting For Beginners - How to do Math in Bash</title>
        <link>https://stream.echo6.co/videos/watch/7261b9cf-93fe-4c08-9cfd-d38ecd9128d1</link>
        <description>In this video I discuss how to do math in bash both with the echo command and the expr command, I also briefly discuss how to format floating point numbers in bash to a specific decimal place. Source code in this video #this will echo the literal string echo 1 + 1 ##you need to use expr instead of echo to get the proper output expr 1 + 1 expr 3 - 2 #you can create variables that equal the result of the calculation this way add_result=$(expr 20 + 8) sub_result=$(expr 20 - 8) #escape the * with a backslash () otherwise you'll get a syntax error here. mul_result=$(expr 20 * 8) div_result=$(expr 20 / 5) rem_result=$(expr 20 % 5) echo '$add_result is equal to '$add_result echo '$sub_result is equal to '$sub_result echo '$mul_result is equal to '$mul_result echo '$div_result is equal to '$div_result echo '$rem_result is equal to '$rem_result num1=50 num2=10 escaping * is not necessary when using echoecho $(( num1 + num2 )) echo $(( num1 - num2 )) echo $(( num1 * num2 )) echo $(( num1 / num2 )) echo $(( num1 % num2 )) #floating point numbers #by default bash cannot do math with decinam numbers, atleast not using expr or echo expr 20 + 0.5 #to avoid errors pipe results into bc, which stands for basic calculator echo "20.5 + 0.4" | bc #this will not give you the proper output because it cuts off the decimal echo "20.5 / 5" | bc #To get past this error we must use the -l command after bc echo "20.5 / 5" | bc -l #use scale to round to a particular decimal place echo "scale=3;20.5 / 5" | bc -l End of Source Code Subscribe to my YouTube channel http://goo.gl/9U10Wz and be sure to click that notification bell so you know when new videos are released. ₿💰💵💲Help Support the Channel by Donating Crypto💲💵💰₿ Dash Xh9PXPEy5RoLJgFDGYCDjrbXdjshMaYerz Zcash t1aWtU5SBpxuUWBSwDKy4gTkT2T1ZwtFvrr Chainlink 0x0f7f21D267d2C9dbae17fd8c20012eFEA3678F14 Bitcoin Cash qz2st00dtu9e79zrq5wshsgaxsjw299n7c69th8ryp Etherum Classic 0xeA641e59913960f578ad39A6B4d02051A5556BfC USD Coin 0x0B045f743A693b225630862a3464B52fefE79FdB Bitcoin bc1qyj5p6hzqkautq4d3zgzwfllm7xv9wjeqkv857z Ethereum 0x35B505EB5b717D11c28D163fb1412C3344c7684d Litecoin LQviuYVbvJs1jCSiEDwWAarycA4xsqJo7D DOGE D7MPGcUT4sXkGroGbs4QVQGyXqXd6QfmXF</description>
        <lastBuildDate>Fri, 17 Apr 2026 08:45:17 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>PeerTube - https://stream.echo6.co</generator>
        <image>
            <title>Bash Shell Scripting For Beginners - How to do Math in Bash</title>
            <url>https://stream.echo6.co/client/assets/images/icons/icon-512x512.png</url>
            <link>https://stream.echo6.co/videos/watch/7261b9cf-93fe-4c08-9cfd-d38ecd9128d1</link>
        </image>
        <copyright>All rights reserved, unless otherwise specified in the terms specified at https://stream.echo6.co/about and potential licenses granted by each content's rightholder.</copyright>
        <atom:link href="https://stream.echo6.co/feeds/video-comments.xml?videoId=7261b9cf-93fe-4c08-9cfd-d38ecd9128d1" rel="self" type="application/rss+xml"/>
    </channel>
</rss>