当前位置:网站首页>Shell tips (134) simple keyboard input recorder
Shell tips (134) simple keyboard input recorder
2022-06-25 07:35:00 【Music master】
Realization effect :
Run script , prompt 4 Characters .
In the input process , Not up to 4 Five characters before display .
Enter the first 4 After characters , Automatically display the entered 4 Characters .
#!/bin/bash
keypresses=4
old_tty_setting=$(stty -g)
echo "Presss $keypresses keys"
stty -icanon -echo
keys=$(dd bs=1 count=$keypresses 2> /dev/null)
stty "$old_tty_setting"
echo "You pressed the \"$keys\" keys."
exit 0

Code brief description :
stty -g Output stty Current settings , Stored in variables old_tty_setting in
stty -icanon -echo The standard input content will not be displayed on the terminal screen
dd bs=1 count=$keypresses 2> /dev/null There's no setup here if, Standard input will be used by default . Match the above stty Set up , Keyboard input is realized ( Standard input ) The content is dd Command to get , Stored in variable keys
stty "$old_tty_setting" Restore the original settings
边栏推荐
- One year's time and University experience sharing with CSDN
- Introduction to Sichuan Tuwei ca-is3082wx isolated rs-485/rs-422 transceiver
- JMeter introduction practice ----- use of global variables and local variables
- Redirect to previous page after login? PHP - Redirecting to previous page after login? PHP
- Hanxin's trick: consistent hashing
- IAR compiler flashback
- How is the network connected?
- 【LeetCode】two num·两数之和
- 【批處理DOS-CMD命令-匯總和小結】-外部命令-cmd下載命令、抓包命令(wget)
- Icon already includes gloss effects
猜你喜欢

Several good weather plug-ins
![[batch dos-cmd command - summary and summary] - external command -cmd download command and packet capture command (WGet)](/img/00/5a5b081b78ad6a6c1c3a3c847dd315.png)
[batch dos-cmd command - summary and summary] - external command -cmd download command and packet capture command (WGet)

Enter an integer with any number of bits, and output the sum of each bit of the number. For example: 1234 – > 10

Common functions of OrCAD schematic

What is the new business model of Taishan crowdfunding in 2022?

Omni toolbox direct download

图扑软件数字孪生 3D 风电场,智慧风电之海上风电

Advanced mathematics foundation_ Parity of functions

【LeetCode】two num·两数之和

STL教程4-输入输出流和对象序列化
随机推荐
诸葛亮 VS 庞统,拿下分布式 Paxos
The king scheme in distributed locks - redisson
Tempest HDMI leak receive 2
313. Binary sum
[XXL job] the pond is green and the wind is warm. I remember that Yu Zhen first met
Conditional grouping with $exists inside $cond
韩信大招:一致性哈希
我与CSDN的一年时光及大学经验分享
14 bs对象.节点名称.name attrs string 获取节点名称 属性 内容
Weimeisi new energy rushes to the scientific innovation board: the annual revenue is 1.7 billion, and the book value of accounts receivable is nearly 400million
Enter an integer with any number of bits, and output the sum of each bit of the number. For example: 1234 – > 10
Unity3D邪门实现之GUI下拉菜单Dropdown设计无重复项
Path planner based on time potential function in dynamic environment
Don't you know the evolution process and principle of such a comprehensive redis cluster model?
Alphassl wildcard certificate for one month
【批处理DOS-CMD命令-汇总和小结】-外部命令-cmd下载命令、抓包命令(wget)
正版photoshop2022購買體驗經曆分享
Chang Wei (variables and constants) is easy to understand
Change the current count of auto increment values in MySQL- Changing the current count of an Auto Increment value in MySQL?
高数基础_函数的奇偶性