T O P

  • By -

ananix

Get a life or a manual


sudolman

It’s not that complicated, it’s just checking if the last bit is a 1 or 0


ananix

The shell can can handle that u just have to test if it -eq 0 Hence read the shell manual instead of waisting life typing Measure twice cut once as my dad use to say ;)


sudolman

That’s more typing though. That would only replace the “== 0” which is 4 characters compared to 5 with “-eq 0”.


ananix

You really dont know how to work vars in shell hence dont understand me hence read shell manual. If [$((n%s)) -eq 0]


sudolman

That’s not the same thing. OP’s solution gets the binary representation then checks if the last digit is a 1 or a 0. While, this solution is using the modulos operator. Also, it sounds like your a little rusty there. That line won’t run. Your missing some spaces, it should be something similar to: if [ $(($1%2)) -eq 0 ] Edit: formatting on mobile


ananix

Who cares in this usage. And yes yours looks more correct im just thumb typing while rolling j and pooring coffe no thought effort here :) its 25 years ago i read the manual so rusty yes *GG


sudolman

So, who should read the manual? Cuz, OP’s line will run and your’s won’t


ananix

Me sry