I am writing a script that takes a lot of user input, then creates a file from that input. Some of the inputs are fairly repetitive, and so I would like to enable the up arrow functionality to include the strings that have already been put in. I am having difficulty finding out how to do this.
I have tried
set -o history
but that only gives me the actual commands run, and not the inputs that have been received. I also know that
"\e[A"
is the up arrow command, but this is as far as I have gotten. A test script is as follows:
#!/bin/bash
set -o history
read -e date
read -e date2
read -e date3
echo $date $date2 $date3
After inputting $date
I would like to be able to up arrow and get the contents of $date
to use for $date2
. Any ideas?