Re: Bash "read" command: want to preload some data
On Sat, Mar 06, 2010 at 06:21:27 -0600, Ron Johnson (firstname.lastname@example.org) wrote:
> 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
> How about:
> read ...
> if [ -z "$FILEPATH" ]
Thanks Ron. I can see what you are getting at, but unless I am missing
something, that still won't display the contents of the string to the
user, providing him or her with the opportunity to accept or edit it.
Bob Cox. Stoke Gifford, near Bristol, UK.
Please reply to the list only. Do NOT send copies directly to me.