Scripting: How would you print an advisory line "at the same time" as your prompt?

C

CrazedNerd

Guest
I'm working on a developed script that makes looking for configuration files that may or may not be used to change something you want to change on your operating system. It starts out like this:

Code:
read -p 'Enter possible file name: ' string
echo 'To skip, just press enter.'

It would look like this when running the script, with a blinking cursor asking the user to enter something on the first line:

Code:
Enter possible file name:
To skip, just press enter.

I could make this easy by putting it all on the same line, but i'm wondering if there's a way i can execute "read" and "echo" at basically the same time so that the user sees them both at once. I'm giving the user an option to skip enter this string because there's also another factor to this search, i want to have both choices optional in terms of how this script flows.
 


I’m not sure this is possible.
Maybe try something like this instead:
Bash:
echo -e "Please enter a file-name\n(or press enter to skip)"
read -p "Filename : " string

Alternatively, you could use an ncurses dialog widget. Rather than explaining it here. Take a look at this:

You could put a prompt onto the dialog and an input box and then have an "Enter" button and a "skip" button.
 
I’m not sure this is possible.
Maybe try something like this instead:
Bash:
echo -e "Please enter a file-name\n(or press enter to skip)"
read -p "Filename : " string

Alternatively, you could use an ncurses dialog widget. Rather than explaining it here. Take a look at this:

You could put a prompt onto the dialog and an input box and then have an "Enter" button and a "skip" button.
It is helpful to know the limits of a programming language
 

Members online


Latest posts

Top