Pre-filling a prompt in Bash

前端 未结 2 989
后悔当初
后悔当初 2021-01-18 05:30

Writing a bash script, and I want to get user input. Awesome,

read -p \"What directory should we save in? \" -e FOLDER

Except that what I\'

相关标签:
2条回答
  • 2021-01-18 06:11
    $ read -p "What directory should we save in? " -i "/home/user/default/" -e FOLDER
    What directory should we save in? /home/user/default/
    

    that should work, right?

    0 讨论(0)
  • 2021-01-18 06:24

    You can wrap the command in rlwrap, which provides instant readline capabilities: http://utopia.knoware.nl/~hlub/rlwrap/#rlwrap

    (rlwrap -P does what you want)

    As far as a pure bash solution is concerned for the 3.2 line (which i am presuming you are using), I dont think its possible

    0 讨论(0)
提交回复
热议问题