I want to simulate keystrokes in my bash script ("Ctrl+B + O" for example) but I do not know how I can do it.

Also, I cannot install any packages for doing this. I want to use this script on Termux.



Contr+A relates to the ASCII value of 1, Contr+B to 2 etc.

If you want to send a control combination, use echo $'\c<key>'.

For example, you can use echo $'\cb'o instead of Contr+B+O.

I tried it out with Termux:

enter image description here

In the second command, I emulated Contr+A using the keys and pressed enter.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.