当前位置:网站首页>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
边栏推荐
- How to store the directory / hierarchy / tree structure in the database- How to store directory / hierarchy / tree structure in the database?
- 从感知机到Transformer,一文概述深度学习简史
- 正版photoshop2022购买体验经历分享
- [batch dos-cmd command - summary and summary] - commands related to Internet access and network communication (Ping, Telnet, NSLOOKUP, ARP, tracert, ipconfig)
- LeetCode 每日一题——515. 在每个树行中找最大值
- Using awk to process input from multiple files
- keepalived監控進程,自動重啟服務進程
- Escape analysis of 982 golang
- 13 `bs_duixiang.tag标签`得到一个tag对象
- 几款不错的天气插件
猜你喜欢
![[batch dos-cmd command - summary and summary] - commands related to Internet access and network communication (Ping, Telnet, NSLOOKUP, ARP, tracert, ipconfig)](/img/9b/283d99adf10262c356d1a87ce01bc0.png)
[batch dos-cmd command - summary and summary] - commands related to Internet access and network communication (Ping, Telnet, NSLOOKUP, ARP, tracert, ipconfig)

Design a MySQL table for message queue to store message data

This year, I graduated

14 bs对象.节点名称.name attrs string 获取节点名称 属性 内容

【pytest】修改allure报告中的logo及参数化

The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse

Evolution of Alibaba e-commerce architecture

Debug through yalc before releasing NPM package

Display purchase Summary - Dell 2705qm BenQ pd2700u

Reading sensor data with GPIO analog SPI interface
随机推荐
【批处理DOS-CMD命令-汇总和小结】-cmd扩展命令、扩展功能(cmd /e:on、cmd /e:off)
【批處理DOS-CMD命令-匯總和小結】-外部命令-cmd下載命令、抓包命令(wget)
对链表进行插入排序[dummy统一操作+断链核心--被动节点]
Harmony美食菜单界面
Display purchase Summary - Dell 2705qm BenQ pd2700u
Debug through yalc before releasing NPM package
太上老君的炼丹炉之分布式 Quorum NWR
Can we use function pointers in go- Can we have function pointers in Go?
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
Reading sensor data with GPIO analog SPI interface
SQL solve select basic statement
Hanxin's trick: consistent hashing
How do I create a guid in excel- How to create a GUID in Excel?
[batch dos-cmd command - summary and summary] - CMD extended command and function (CMD /e:on, CMD /e:off)
keepalived監控進程,自動重啟服務進程
Analysis on the trend of the number of national cinemas, film viewers and average ticket prices in 2021 [figure]
Google extender address
How is the network connected?
How to store the directory / hierarchy / tree structure in the database- How to store directory / hierarchy / tree structure in the database?
Let's talk about MCU crash caused by hardware problems