I am a newbie with Shell Scripting who stuck while creating a shell script for Pythagoras theorem.I need to know how to add the squares for the value in shell scripting(for eg: b2 =a2 +c2).
Thanks
VR
Last edited by VoraciousReader; 11-28-2014 at 03:11 AM..
If you have a 1993 or later version of the Korn shell, save the following in a file named pythagorus:
and make it executable with:
and invoke it with two operands such as one of the following:
you'll get output like:
and
respectively.
If you don't have a recent ksh, you can use the following script using dc (which is the back end to the bc utility on many systems) with any shell that accepts basic Bourne shell syntax (such as bash, dash, ksh, or (on almost any system) /bin/sh):
and with the same three commands, get the output:
and
Last edited by Don Cragun; 11-28-2014 at 07:36 AM..
Reason: Remove extraneous printf call from my internal tests.
This User Gave Thanks to Don Cragun For This Post:
hi all i have a reporting work and i want it to be automated using shell scripting kindly let me know how can i make that possibe .
eg data are :... (2 Replies)
Hi
After lot of trial and error I am really bowled out with the requirement in hand and honestly you are my last hope
Here is what I want to achieve
Values
*IF *VALUE MS_SQL_Statistics_Summary.Client_Count_Percent_Used *GT 70.00 *AND *VALUE... (20 Replies)
hey i am using this code to connect to sql , store the value in variable and then
compare it with another variable after some time by executing the same query
but the desired result is not coming
#!/bin/bash
val=$(sqlplus -s rte/rted2@rel76d2 <<ENDOFSQL
set heading off
set feedback off... (11 Replies)
hi
My script as below
#!/bin/ksh
for i in `seq 1 7`
do
a=$(awk '{print $i}' /home/rama/expenese.txt)
done
for i in `seq 1 7`
do
echo "${a}"
done
content of expense.txt is as below
5032 210179 3110 132813874 53488966 11459221 5300794
I want output as... (6 Replies)
Hi Guys,
I want to set a variable which happend to have square brackets in them. I tried multiple ways that is by escaping it with quotes (both single and double ) but it didn't help.
All I want is:
set x = slicearray.slice\.post
My failed attempts were:
set x = "slicearray.slice\.post"... (3 Replies)
Hello,
I don't have experience in this scripting and I need some help to read a value from an XML file and change it with a random number to use in simulator for different network scenarios.
</Description><sim_comm_rounds>35</sim_comm_rounds><num_clusters>1</num_clusters><Clocking>
I want to... (5 Replies)
Hi All,
I have a text file which looks like this:
computer programming
systems engineering
I want to get rid of these square brackets and also the text that is inside these brackets. So that my final text file looks like this:
computer programming
systems engineering
I am using... (3 Replies)
Hi All,
I want to concatenate the array cell values and form a string.. Is it possible?
for ex.
I have an array
word_array contains d u m b and after concatenating the string shld be 'dumb'
thanks (2 Replies)