How to obtain only positive value in second column [closed]How to extract the positive numbers in the first column from an output as in the question?Using awk to change an entire column of both positive and negative values, to just negative?Is it possible to add consecutive columns in AWKMerge two files and plus the second column using AWKHow to print first column of next line in current line?How to print a specific column condition using awk?Calculate interval if value in column changesget average for all numbers with irregular columnsHow to obtain the last recently three dates of a file log?How to collapse consecutive numbers into ranges?
Does the Paladin's Aura of Protection affect only either her or ONE ally in range?
Why cruise at 7000' in an A319?
Does anycast addressing add additional latency in any way?
What determines the "strength of impact" of a falling object on the ground, momentum or energy?
C-152 carb heat on before landing in hot weather?
Intuitively, why does putting capacitors in series decrease the equivalent capacitance?
Should my manager be aware of private LinkedIn approaches I receive? How to politely have this happen?
Is my Rep in Stack-Exchange Form?
How can I convince my reader that I will not use a certain trope?
"It will become the talk of Paris" - translation into French
MH370 blackbox - is it still possible to retrieve data from it?
How to determine what is the correct level of detail when modelling?
A player is constantly pestering me about rules, what do I do as a DM?
Was touching your nose a greeting in second millenium Mesopotamia?
Mount a folder with a space on Linux
Find smallest index that is identical to the value in an array
Using “sparkling” as a diminutive of “spark” in a poem
What is this opening trap called, and how should I play afterwards? How can I refute the gambit, and play if I accept it?
What do you call the action of someone tackling a stronger person?
Does squid ink pasta bleed?
How risky is real estate?
Do French speakers not use the subjunctive informally?
How could mana leakage be dangerous to a elf?
Going to get married soon, should I do it on Dec 31 or Jan 1?
How to obtain only positive value in second column [closed]
How to extract the positive numbers in the first column from an output as in the question?Using awk to change an entire column of both positive and negative values, to just negative?Is it possible to add consecutive columns in AWKMerge two files and plus the second column using AWKHow to print first column of next line in current line?How to print a specific column condition using awk?Calculate interval if value in column changesget average for all numbers with irregular columnsHow to obtain the last recently three dates of a file log?How to collapse consecutive numbers into ranges?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I use this command
awk 'NR%2t=$1;nextprint $1-t,$2'
to get the distance between two consecutive Y points in a file. But I would like to have all positive numbers. How to get that ? like something as modulus.
1577 -46.1492
1577.57 47
1578 -47.6528
1578.87 49
1579 -49.2106
1580 -50.7742
1580.15 51
awk numeric-data
closed as unclear what you're asking by Kusalananda♦, jimmij, msp9011, Jeff Schaller♦, Anthony Geoghegan Mar 25 at 15:12
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I use this command
awk 'NR%2t=$1;nextprint $1-t,$2'
to get the distance between two consecutive Y points in a file. But I would like to have all positive numbers. How to get that ? like something as modulus.
1577 -46.1492
1577.57 47
1578 -47.6528
1578.87 49
1579 -49.2106
1580 -50.7742
1580.15 51
awk numeric-data
closed as unclear what you're asking by Kusalananda♦, jimmij, msp9011, Jeff Schaller♦, Anthony Geoghegan Mar 25 at 15:12
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.
– Kusalananda♦
Mar 25 at 9:47
add a comment |
I use this command
awk 'NR%2t=$1;nextprint $1-t,$2'
to get the distance between two consecutive Y points in a file. But I would like to have all positive numbers. How to get that ? like something as modulus.
1577 -46.1492
1577.57 47
1578 -47.6528
1578.87 49
1579 -49.2106
1580 -50.7742
1580.15 51
awk numeric-data
I use this command
awk 'NR%2t=$1;nextprint $1-t,$2'
to get the distance between two consecutive Y points in a file. But I would like to have all positive numbers. How to get that ? like something as modulus.
1577 -46.1492
1577.57 47
1578 -47.6528
1578.87 49
1579 -49.2106
1580 -50.7742
1580.15 51
awk numeric-data
awk numeric-data
edited Mar 25 at 9:44
Jeff Schaller♦
47.1k11 gold badges68 silver badges153 bronze badges
47.1k11 gold badges68 silver badges153 bronze badges
asked Mar 25 at 9:31
newstudentnewstudent
454 bronze badges
454 bronze badges
closed as unclear what you're asking by Kusalananda♦, jimmij, msp9011, Jeff Schaller♦, Anthony Geoghegan Mar 25 at 15:12
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Kusalananda♦, jimmij, msp9011, Jeff Schaller♦, Anthony Geoghegan Mar 25 at 15:12
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.
– Kusalananda♦
Mar 25 at 9:47
add a comment |
2
It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.
– Kusalananda♦
Mar 25 at 9:47
2
2
It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.
– Kusalananda♦
Mar 25 at 9:47
It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.
– Kusalananda♦
Mar 25 at 9:47
add a comment |
2 Answers
2
active
oldest
votes
Command: awk '$2 !~ /^-/print $0' file
output
1577.57 47
1578.87 49
1580.15 51
add a comment |
You can replace this:
print $1-t,$2
with this:
if ($2>=0) print $1-t,$2
or,
$2 >= 0 print $1 - t, $2
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Command: awk '$2 !~ /^-/print $0' file
output
1577.57 47
1578.87 49
1580.15 51
add a comment |
Command: awk '$2 !~ /^-/print $0' file
output
1577.57 47
1578.87 49
1580.15 51
add a comment |
Command: awk '$2 !~ /^-/print $0' file
output
1577.57 47
1578.87 49
1580.15 51
Command: awk '$2 !~ /^-/print $0' file
output
1577.57 47
1578.87 49
1580.15 51
answered Mar 25 at 9:42
Praveen Kumar BSPraveen Kumar BS
2,1692 gold badges3 silver badges11 bronze badges
2,1692 gold badges3 silver badges11 bronze badges
add a comment |
add a comment |
You can replace this:
print $1-t,$2
with this:
if ($2>=0) print $1-t,$2
or,
$2 >= 0 print $1 - t, $2
add a comment |
You can replace this:
print $1-t,$2
with this:
if ($2>=0) print $1-t,$2
or,
$2 >= 0 print $1 - t, $2
add a comment |
You can replace this:
print $1-t,$2
with this:
if ($2>=0) print $1-t,$2
or,
$2 >= 0 print $1 - t, $2
You can replace this:
print $1-t,$2
with this:
if ($2>=0) print $1-t,$2
or,
$2 >= 0 print $1 - t, $2
edited Mar 25 at 9:46
Kusalananda♦
152k18 gold badges300 silver badges479 bronze badges
152k18 gold badges300 silver badges479 bronze badges
answered Mar 25 at 9:35
Romeo NinovRomeo Ninov
7,5443 gold badges21 silver badges29 bronze badges
7,5443 gold badges21 silver badges29 bronze badges
add a comment |
add a comment |
2
It is unclear (as you can see from the answers) whether the data that you present is input to your existing awk script or output from it.
– Kusalananda♦
Mar 25 at 9:47