How to obtain only positive value in second column [on hold]
I use this command
awk 'NR%2{t=$1;next}{print $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
put on hold as unclear what you're asking by Kusalananda, jimmij, msp9011, Jeff Schaller, Anthony Geoghegan 22 hours ago
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%2{t=$1;next}{print $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
put on hold as unclear what you're asking by Kusalananda, jimmij, msp9011, Jeff Schaller, Anthony Geoghegan 22 hours ago
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
yesterday
add a comment |
I use this command
awk 'NR%2{t=$1;next}{print $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%2{t=$1;next}{print $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 yesterday
Jeff Schaller
43.9k1161141
43.9k1161141
asked yesterday
newstudentnewstudent
262
262
put on hold as unclear what you're asking by Kusalananda, jimmij, msp9011, Jeff Schaller, Anthony Geoghegan 22 hours ago
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.
put on hold as unclear what you're asking by Kusalananda, jimmij, msp9011, Jeff Schaller, Anthony Geoghegan 22 hours ago
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
yesterday
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
yesterday
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
yesterday
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
yesterday
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 yesterday
Praveen Kumar BSPraveen Kumar BS
1,6821311
1,6821311
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 yesterday
Kusalananda
138k17258426
138k17258426
answered yesterday
Romeo NinovRomeo Ninov
6,86432129
6,86432129
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
yesterday