[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash "read" command: want to preload some data



On 2010-03-06 04:28, Bob Cox wrote:
What I am trying to do is "preload" a bash read command with a value
which can be accepted, edited or changed by the user.  Some googling
shows that this is dead easy to with the -i option which appeared in
bash version 4 - I have found this:

---------------------
Example: ask for a path with a default value.
Note: The -i option was introduced with Bash 4.
read -e -p "Enter the path to the file: " -i "/usr/local/etc/" FILEPATH
The user will be prompted, he can just accept the default, or edit it.
---------------------

This is exactly what I want.  However, for the sake of compatibility, I
would like to do the same thing using older versions of bash, even if it
means messier coding.  Does anyone have any ideas on how to do this
please?


How about:

    read ...
    if [ -z "$FILEPATH" ]
    then
       FILRPATH=/usr/local/etc/"
    if

--
Ron Johnson, Jr.
Jefferson LA  USA

"If God had wanted man to play soccer, he wouldn't have given
us arms."  Mike Ditka


Reply to: