Linux how to use stty command

  

Linux command, stty command is mainly used to print or modify the terminal settings, plus various parameters can achieve different functions, the following small series will be for the stty command in Linux application for everyone to do A brief introduction, I hope to provide some help to friends who do not understand.

1, the command line, output prohibiting uppercase method

stty -icanon read operation is provided disposable, such as using getchar () reads without pressing enter < Br>

stty icanon cancel the above settings

stty -a view information

stty -echo set command is not displayed

stty echo cancels no display

stty raw -echo

stty raw echo

stty iuclc #开启

stty -iuclc #restore

2, prohibited at the command line Output lowercase

stty olcuc #开启

stty -olcuc#recover

3, print out the number of rows and columns of the terminal

stty size

4, change the ctrl+D method:

stty eof “string”

The system default is ctrl+D to indicate the end of the file, and by this method, change!

5, shield display

stty -echo # disable echo

stty echo #open echo

Test method:

Stty -echo;read;stty echo;read

6. Ignore carriage returns

stty igncr #开启

stty -igncr#recover

7 Timed input

timeout_read()

{

timeout=$1

old_stty_settings=`stty -g` #save current settings

stty -icanon min 0 time 100 #set 10seconds,not 100seconds

eval read varname #=read $varname

stty “$old_stty_settings” #recover settings

}

The simpler way is to use the -t option of the read command

read -t 10 varname

The above is the way to use the stty command on Linux. By stty command you You can make various settings for the terminal, such as prohibiting input of uppercase letters, ignoring carriage returns, etc., and practicing these to grasp these usages.

Copyright © Windows knowledge All Rights Reserved