How to read (command) without enter in Linux bash shell?

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World
By default the read command wait for a Enter Key to complete the command. But if  you –n 1 option it will not wait for the enter key. Once it counts one(n=1) key press in the standard input it will come out and assign the value to the variable.

Normal read command with enter


read -p "Are you Sure?" ans
Are you Sure?y
$ echo $ans
Y

Read command without enter

read -p " Are you Sure?" -n 1 ans
Are you Sure?y$
$ echo $ans
y

How to implement in shell script?

proceed=$(bash -c 'read -p " Are you Sure ? " -n 1 ans;echo "$ans"')

_____________________________________________________________________________________________________________________

A visitor from Posadas viewed 'Scripts to Check RMAN Backup Status and Progress' 3 hrs 27 mins ago
A visitor from Columbia viewed 'How to Find out / Check SGA and PGA size of Oracle' 5 hrs 39 mins ago
A visitor from Poljcane viewed 'How to Exclude MLOG$ Materialized View Log Tables ' 6 hrs 40 mins ago
A visitor from Virginia viewed 'Fix ORA-01504: database name 'RESTRICT' does not m' 7 hrs 11 mins ago
A visitor from Valparaiso viewed 'Data Guard / Standby: ORA-01156: recovery or flash' 8 hrs 55 mins ago

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-25 All Rights Reserved | Site Map | Contact | Disclaimer