How do i prevent typed text being seen when running shell scripts?



  • Interactive shell scripts may require you to enter sensitive data, to prevent this text being seen when typed, use the -s option of the read command.

    ...
    ...
    read -s -p "What is your favourite fruit? " fruit
    echo
    ...
    ...
    

    The result is: When the response is entered the characters are not visible.

    $ ./myfruit.sh
    What is your favourite fruit? 
    $
    

Log in to reply
 

© Lightnetics 2024