Bash input without pausing the script?
问题 In Bash the only way to get a (user) input seems to be to use the read method, which pauses the rest of the script. Is there any way to receive a command line input (ending with the enter key) without pausing the script. From what I've seen there may be a way to do it with $1 ..? 回答1: read -t0 can be used to probe for input if your process is structured as a loop #!/bin/bash a='\|/-' spin() { sleep 0.3 a="${a:1}${a:0:1}" echo -n $'\e'7$'\r'"${a:1:1}"$'\e'8 } echo 'try these /|\- , dbpq , |)>)