Add values in different rowsUsing getline with NR in awkConvert rows to columnsLinux last 5 logins for every...

Academic progression in Germany, what happens after a postdoc? What is the next step?

UX writing: When to use "we"?

Word for giving preference to the oldest child

Patio gate not at right angle to the house

Was Donald Trump at ground zero helping out on 9-11?

Why does Latex make a small adjustment when I change section color

What force enables us to walk? Friction or normal reaction?

What is my clock telling me to do?

Scam? Checks via Email

Why was the Lobbying Transparency and Accountability Act of 2006 deemed too weak?

Why are prop blades not shaped like household fan blades?

How and why does the ATR-72 sometimes use reverse thrust to push back from the gate?

How to structure presentation to avoid getting questions that will be answered later in the presentation?

Can I use log and without any transformation variables in the one model for the independent variables?

Why do we need a voltage divider when we get the same voltage at the output as the input?

How do discovery writers hibernate?

Applications of pure mathematics in operations research

How can flights operated by the same company have such different prices when marketed by another?

Best Ergonomic Design for a handheld ranged weapon

My employer is refusing to give me the pay that was advertised after an internal job move

Create and use Object Variable

Derivative is just speed of change?

Prepare a user to perform an action before proceeding to the next step

Using Python in a Bash Script



Add values in different rows


Using getline with NR in awkConvert rows to columnsLinux last 5 logins for every userUsing 'awk' to print a placeholder in several blocks of dataPrint values which are at least 2 times larger than the values 3 steps above and below in the same columnreading output into variables inside the os.system commandHow to find lines with different values in 5th column which share the same 2nd column?Rounding a number in awkgrepping HPC jobsHow to prevent printing to stdout from an awk **script** (not from cli)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I have this table:



enter image description here



My script is:



#!/usr/bin/bash
sd2=`iostat -xz | awk '/sd2/ {print $8}'`

sd3=`iostat -xz | awk '/sd3/ {print $8}'`

delta=$sd2-$sd3

echo "Message: Hard Drive Service Time Delta"

echo "Data:"

printf $delta


The output of script is: 0.4-0.4



Question: What do I need to do to get the output: 0



Tia!










share|improve this question









New contributor



Sevdale Corpuz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • you should try bc or awk

    – msp9011
    1 hour ago


















0















I have this table:



enter image description here



My script is:



#!/usr/bin/bash
sd2=`iostat -xz | awk '/sd2/ {print $8}'`

sd3=`iostat -xz | awk '/sd3/ {print $8}'`

delta=$sd2-$sd3

echo "Message: Hard Drive Service Time Delta"

echo "Data:"

printf $delta


The output of script is: 0.4-0.4



Question: What do I need to do to get the output: 0



Tia!










share|improve this question









New contributor



Sevdale Corpuz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • you should try bc or awk

    – msp9011
    1 hour ago














0












0








0








I have this table:



enter image description here



My script is:



#!/usr/bin/bash
sd2=`iostat -xz | awk '/sd2/ {print $8}'`

sd3=`iostat -xz | awk '/sd3/ {print $8}'`

delta=$sd2-$sd3

echo "Message: Hard Drive Service Time Delta"

echo "Data:"

printf $delta


The output of script is: 0.4-0.4



Question: What do I need to do to get the output: 0



Tia!










share|improve this question









New contributor



Sevdale Corpuz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have this table:



enter image description here



My script is:



#!/usr/bin/bash
sd2=`iostat -xz | awk '/sd2/ {print $8}'`

sd3=`iostat -xz | awk '/sd3/ {print $8}'`

delta=$sd2-$sd3

echo "Message: Hard Drive Service Time Delta"

echo "Data:"

printf $delta


The output of script is: 0.4-0.4



Question: What do I need to do to get the output: 0



Tia!







awk






share|improve this question









New contributor



Sevdale Corpuz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



Sevdale Corpuz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 1 hour ago









msp9011

5,4275 gold badges43 silver badges69 bronze badges




5,4275 gold badges43 silver badges69 bronze badges






New contributor



Sevdale Corpuz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 1 hour ago









Sevdale CorpuzSevdale Corpuz

31 bronze badge




31 bronze badge




New contributor



Sevdale Corpuz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Sevdale Corpuz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • you should try bc or awk

    – msp9011
    1 hour ago



















  • you should try bc or awk

    – msp9011
    1 hour ago

















you should try bc or awk

– msp9011
1 hour ago





you should try bc or awk

– msp9011
1 hour ago










1 Answer
1






active

oldest

votes


















0














Try this,



delta=$(bc <<< "$sd2-$sd3")


or



delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')





share|improve this answer





















  • 1





    Both works. Thank You!

    – Sevdale Corpuz
    53 mins ago














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Sevdale Corpuz is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f533498%2fadd-values-in-different-rows%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Try this,



delta=$(bc <<< "$sd2-$sd3")


or



delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')





share|improve this answer





















  • 1





    Both works. Thank You!

    – Sevdale Corpuz
    53 mins ago
















0














Try this,



delta=$(bc <<< "$sd2-$sd3")


or



delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')





share|improve this answer





















  • 1





    Both works. Thank You!

    – Sevdale Corpuz
    53 mins ago














0












0








0







Try this,



delta=$(bc <<< "$sd2-$sd3")


or



delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')





share|improve this answer













Try this,



delta=$(bc <<< "$sd2-$sd3")


or



delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')






share|improve this answer












share|improve this answer



share|improve this answer










answered 59 mins ago









msp9011msp9011

5,4275 gold badges43 silver badges69 bronze badges




5,4275 gold badges43 silver badges69 bronze badges











  • 1





    Both works. Thank You!

    – Sevdale Corpuz
    53 mins ago














  • 1





    Both works. Thank You!

    – Sevdale Corpuz
    53 mins ago








1




1





Both works. Thank You!

– Sevdale Corpuz
53 mins ago





Both works. Thank You!

– Sevdale Corpuz
53 mins ago










Sevdale Corpuz is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Sevdale Corpuz is a new contributor. Be nice, and check out our Code of Conduct.













Sevdale Corpuz is a new contributor. Be nice, and check out our Code of Conduct.












Sevdale Corpuz is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f533498%2fadd-values-in-different-rows%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...