One of option might be the following

[![enter image description here][2]][2]

**figure [source with video](https://www.youtube.com/watch?v=KUntDnYyVN4)**

You can adjust the contours of the cam to create a more square profile. 

---
## linear actuators 

There are linear actuators different versions e.g. with a solinoid or with a planetary gear system e.g. [see](https://www.robotshop.com/en/actuonix-p16-linear-actuator-50mm-2561-12v-w--limit-switches.html). 

However if they are applicable to your problem is depended on :
- cost 
- the forces that you need to apply
- the maximum velocity and acceleration profile. 


  [1]: https://i.sstatic.net/WIBuV.jpg
  [2]: https://i.sstatic.net/5SCby.gif