Find the largest positive number in my given data?
Can someone show me a way to find the largest positive number using awk,sed or some sort of unix shell program. Im using Linux RHEL with KSH. The input may have 8 columns worth of data with N/A as one of the possible values.
SAMPLE INPUT
1252.2 1251.8 N/A N/A
-31.9 -33.2 N/A N/A
-1172.4 -1174.4 N/A N/A
-6.5 -6.4 N/A N/A
-.3 -.3 N/A N/A
1351.8 1351.8 N/A N/A
38.3 38.0 N/A N/A
-21.6 -21.9 N/A N/A
-4.7 -4.5 N/A N/A
-5.0 -2.9 N/A N/A
3.1 3.3 N/A N/A
-20.1 -20.3 N/A N/A
-199.1 -199.3 N/A N/A
346.5 346.7 N/A N/A
-.8 -.4 N/A N/A
14.8 14.7 N/A N/A
8.4 8.4 N/A N/A
-18.2 -18.2 N/A N/A
-43.7 -43.6 N/A N/A
Desired output
Largest number is 1351.8
shell-script awk sed ksh
add a comment |
Can someone show me a way to find the largest positive number using awk,sed or some sort of unix shell program. Im using Linux RHEL with KSH. The input may have 8 columns worth of data with N/A as one of the possible values.
SAMPLE INPUT
1252.2 1251.8 N/A N/A
-31.9 -33.2 N/A N/A
-1172.4 -1174.4 N/A N/A
-6.5 -6.4 N/A N/A
-.3 -.3 N/A N/A
1351.8 1351.8 N/A N/A
38.3 38.0 N/A N/A
-21.6 -21.9 N/A N/A
-4.7 -4.5 N/A N/A
-5.0 -2.9 N/A N/A
3.1 3.3 N/A N/A
-20.1 -20.3 N/A N/A
-199.1 -199.3 N/A N/A
346.5 346.7 N/A N/A
-.8 -.4 N/A N/A
14.8 14.7 N/A N/A
8.4 8.4 N/A N/A
-18.2 -18.2 N/A N/A
-43.7 -43.6 N/A N/A
Desired output
Largest number is 1351.8
shell-script awk sed ksh
add a comment |
Can someone show me a way to find the largest positive number using awk,sed or some sort of unix shell program. Im using Linux RHEL with KSH. The input may have 8 columns worth of data with N/A as one of the possible values.
SAMPLE INPUT
1252.2 1251.8 N/A N/A
-31.9 -33.2 N/A N/A
-1172.4 -1174.4 N/A N/A
-6.5 -6.4 N/A N/A
-.3 -.3 N/A N/A
1351.8 1351.8 N/A N/A
38.3 38.0 N/A N/A
-21.6 -21.9 N/A N/A
-4.7 -4.5 N/A N/A
-5.0 -2.9 N/A N/A
3.1 3.3 N/A N/A
-20.1 -20.3 N/A N/A
-199.1 -199.3 N/A N/A
346.5 346.7 N/A N/A
-.8 -.4 N/A N/A
14.8 14.7 N/A N/A
8.4 8.4 N/A N/A
-18.2 -18.2 N/A N/A
-43.7 -43.6 N/A N/A
Desired output
Largest number is 1351.8
shell-script awk sed ksh
Can someone show me a way to find the largest positive number using awk,sed or some sort of unix shell program. Im using Linux RHEL with KSH. The input may have 8 columns worth of data with N/A as one of the possible values.
SAMPLE INPUT
1252.2 1251.8 N/A N/A
-31.9 -33.2 N/A N/A
-1172.4 -1174.4 N/A N/A
-6.5 -6.4 N/A N/A
-.3 -.3 N/A N/A
1351.8 1351.8 N/A N/A
38.3 38.0 N/A N/A
-21.6 -21.9 N/A N/A
-4.7 -4.5 N/A N/A
-5.0 -2.9 N/A N/A
3.1 3.3 N/A N/A
-20.1 -20.3 N/A N/A
-199.1 -199.3 N/A N/A
346.5 346.7 N/A N/A
-.8 -.4 N/A N/A
14.8 14.7 N/A N/A
8.4 8.4 N/A N/A
-18.2 -18.2 N/A N/A
-43.7 -43.6 N/A N/A
Desired output
Largest number is 1351.8
shell-script awk sed ksh
shell-script awk sed ksh
asked 13 mins ago
ayrton_sennaayrton_senna
5122419
5122419
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
One way can be:
perl -lane '$_>$m and $m=$_ for @F}{print $m' sample.txt
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
});
}
});
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%2f502616%2ffind-the-largest-positive-number-in-my-given-data%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
One way can be:
perl -lane '$_>$m and $m=$_ for @F}{print $m' sample.txt
add a comment |
One way can be:
perl -lane '$_>$m and $m=$_ for @F}{print $m' sample.txt
add a comment |
One way can be:
perl -lane '$_>$m and $m=$_ for @F}{print $m' sample.txt
One way can be:
perl -lane '$_>$m and $m=$_ for @F}{print $m' sample.txt
answered 5 mins ago
Rakesh SharmaRakesh Sharma
314113
314113
add a comment |
add a comment |
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%2f502616%2ffind-the-largest-positive-number-in-my-given-data%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