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 8613783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:57:57+00:00 2026-06-12T04:57:57+00:00

TEST1=`echo $QUERY_DAYS3 | awk ‘{print $1}’` echo $TEST1 TEST2=`echo $QUERY_DAYS3 | awk ‘{print $2}’`

  • 0
TEST1=`echo $QUERY_DAYS3 | awk '{print $1}'`
echo $TEST1

TEST2=`echo $QUERY_DAYS3 | awk '{print $2}'`
echo $TEST2

mailx -s "Data Report" -r uname@host.com uname@host.com <<EOF

Error Percentage: $((100 * ($TEST2/ $TEST1)))

EOF

In my bash Shell script I have the above code from which I am sending email. But when I check my email I always see Error Percentage written like as it is written in my above code. It is not evaluating the multiplication and division expression.

I am running the above script like this-

sh -x test1.sh

In the email I get like this-

Error  Percentage: $((100 * (183563 / 3793277)))

I am running SunOS.

May be I need to use Back-Ticks here?

Update:-

My updated script that I am using currently-

TEST1=`echo $QUERY_DAYS3 | awk '{print $1}'`
echo $TEST1

TEST2=`echo $QUERY_DAYS3 | awk '{print $2}'`
echo $TEST2

mailx -s "Data Report" -r uname@host.com uname@host.com <<EOF

Error Percentage: $(( 100 * $TEST2 ) / $TEST1)

EOF

I am running it like this below-

sh -c 'exec ./test.sh'

After trying the suggestion given by lot of peoples. I am getting this error-

./test.sh: command substitution: line 176: syntax error near unexpected token `/'
./test.sh: command substitution: line 176: `( 100 * $TEST2 ) / $TEST1'

What wrong I am doing now? Any thoughts?

Update:-

After making changes, it start working-

Mismatch  Percentage: $((( 100 * $TEST2 ) / $TEST1))

But in the email, the percentage I get was rounded to only one figure like 4 only instead of showing as 4.34563235 How can I get full numbers instead of getting rounded off to one digit.?

  • 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-12T04:57:58+00:00Added an answer on June 12, 2026 at 4:57 am

    You can’t expect it to run under bash, if you explicitely tell sh to execute it…
    Try

    bash -x test1.sh
    

    Having

    #!/bin/bash
    

    as the first line, will only work if you directly execute the script:

    ./test1.sh
    

    It needs to be ‘executable’ for that to work

    chmod +x test1.sh
    

    Update

    Error Percentage: $(( 100 * $TEST2 ) / $TEST1)
    

    needs to be

    Error Percentage: $((( 100 * $TEST2 ) / $TEST1))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have 2 scripts test1.sh #!/bin/sh . ./test2.sh foo test2.sh #!/bin/sh foo(){ echo
table: test1 ---------- |id |name| ---------- |46 |BOB | ---------- table: test2 ------------------------ |id
I can't figure out why... This works: <?php if($_POST['test']) echo posted; ?> <form method=POST
I have a batch script that looks like this: Test.bat @echo off :: Starts
I have scrip contain command line: set dir=%1 cd %dir% test.bat echo successful When
#test code: #!/bin/bash #~/test/test.sh trap echo 'testmessage' DEBUG while : do echo abc sleep
<table> while ($row = mysql_fetch_assoc($result)) { <tr> <td> echo $row['test'] . . ' ($'
When executing echo 0 > test.txt in cmd.exe, the output in test.txt is 0_
#!/bin/bash if test $# == 4; then echo $*; else echo args-error >&2; fi;
Consider this class: class test { public function __set($n, $v) { echo __set() called\n;

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.