how to compile arduino sketch from termnial without using arduino ide
As a contributor to Sloeber, an Eclipse Plugin dedicated to Arduino and other micro controllers, I can tell you it's all a matter of using the correct version of gcc and provide the correct options.

Even if that might seem simple, it's not like that, so my advice is to download Sloeber and look at the build console output where we print all the statements used to fulfill the build task: you can infer a lot from that.

As Sloeber is also open source, you can also inspect how we create those build commands for the different boards and tool chains.