Harvey
Harvey

Reputation: 2222

bash prompt user to edit string and enter

I want to present the user with a string to edit and enter. For example:

$edpath filen*
 Edit> /home/user1/bla/bla/foo/bar/bar/dir1/dir2/filename.xyz

And after the user edits the string and hits enter:

You entered: /home/user2/foobar/dir1/dir2/filename.xyz
$

What bash command does this, if any?

Upvotes: 1

Views: 198

Answers (1)

Etan Reisner
Etan Reisner

Reputation: 80921

For bash 4.1+ (or so, I'm not sure of the exact version).

$ read -re -p 'Edit> ' -i '/home/user1/bla/bla/foo/bar/bar/dir1/dir2/filename.xyz' filename
$ echo "You entered: $filename"

Upvotes: 2

Related Questions