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;
}
I have this table:
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
New contributor
add a comment |
I have this table:
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
New contributor
you should trybc
orawk
– msp9011
1 hour ago
add a comment |
I have this table:
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
New contributor
I have this table:
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
awk
New contributor
New contributor
edited 1 hour ago
msp9011
5,4275 gold badges43 silver badges69 bronze badges
5,4275 gold badges43 silver badges69 bronze badges
New contributor
asked 1 hour ago
Sevdale CorpuzSevdale Corpuz
31 bronze badge
31 bronze badge
New contributor
New contributor
you should trybc
orawk
– msp9011
1 hour ago
add a comment |
you should trybc
orawk
– msp9011
1 hour ago
you should try
bc
or awk
– msp9011
1 hour ago
you should try
bc
or awk
– msp9011
1 hour ago
add a comment |
1 Answer
1
active
oldest
votes
Try this,
delta=$(bc <<< "$sd2-$sd3")
or
delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')
1
Both works. Thank You!
– Sevdale Corpuz
53 mins ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Try this,
delta=$(bc <<< "$sd2-$sd3")
or
delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')
1
Both works. Thank You!
– Sevdale Corpuz
53 mins ago
add a comment |
Try this,
delta=$(bc <<< "$sd2-$sd3")
or
delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')
1
Both works. Thank You!
– Sevdale Corpuz
53 mins ago
add a comment |
Try this,
delta=$(bc <<< "$sd2-$sd3")
or
delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')
Try this,
delta=$(bc <<< "$sd2-$sd3")
or
delta=$(echo $sd2 $sd3 |awk '{print $1-$2}')
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
add a comment |
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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
you should try
bc
orawk
– msp9011
1 hour ago