Search Results

Search: Posts Made By: ksennin
1,022
Posted By Scott
You can simply use an if statement to test if the...
You can simply use an if statement to test if the value is above or below the threshold and set the field to 1 or 0 based on that.

awk '{$2=($2<n)?0:1}1'

where n is the desired threshold (e.g....
5,013
Posted By RudiC
With a recent bash that provides "process...
With a recent bash that provides "process substitution", try
join <(join file[12]) <(join file[34])
5,013
Posted By jgt
read the man pages for the cut and paste...
read the man pages for the cut and paste commands.

---------- Post updated at 10:05 AM ---------- Previous update was at 10:01 AM ----------



use the cut command to retrieve only the second...
14,970
Posted By MadeInGermany
The "if?then:else" is a "value if", a ternary...
The "if?then:else" is a "value if", a ternary operator.
Here with another ternary operator in the "else".

In your explicit if-then-else clause it must be
else if ($3 == $2) because $3 = $2 is an...
14,970
Posted By RudiC
So you've done it on your own! Congrats! ...
So you've done it on your own! Congrats!

Next time you might consider
awk '{print $1, ($2>$3)?0:($2<$3)?1:2}' file3
label1 0
label2 0
label3 1
label4 2
label5 1
label6 0 as well.
14,970
Posted By RudiC
Mayhap another if ... then ... construct?
Mayhap another if ... then ... construct?
3,879
Posted By MadeInGermany
Thanks to the example things are clear now. ...
Thanks to the example things are clear now.
#!/bin/sh
awk '
function maxcol(startcol,endcol){
_maxcol=$startcol
while (++startcol<=endcol) {
if ($startcol>_maxcol)...
Showing results 1 to 7 of 7

 
All times are GMT -4. The time now is 05:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy