1754296 Members
3072 Online
108813 Solutions
New Discussion юеВ

Scripting question

 
SOLVED
Go to solution
Brian M. Fisher
Honored Contributor

Scripting question

Is this something do-able in unix script?

I have a variable x.
I read the input for it. Do some stuff and ask for another x.

Can I somehow display the current value of the x and have them back space over some random number of characters and put that as the "new" value?

An example is:
I prompt the user to enter a long number "x":
1098765432123456789
What I would like to do is after processing "x", print out "x" and allow them to backspace over 89 for value 90, without keying in the entire variable again.
i.e. 1098765432123456789 -> 1098765432123456790

Any ideas?
Thanks,
Brian
<*(((>< er
Perception IS Reality
6 REPLIES 6
H.Merijn Brand (procura
Honored Contributor

Re: Scripting question

# perl -MMath::BigInt -MTerm::ReadLine::Perl ...
Enjoy, Have FUN! H.Merijn
Tom Jackson
Valued Contributor

Re: Scripting question

This is simple and works:

typeset test1=123456789
read test2?"${test1}: "
echo $test1
echo $test2

In the script above, the test1 variable is used as a prompt. You can select, cut and paste using your mouse, then make appropriate edits. Then test2 gets the value you enter.

Tom
Jean-Louis Phelix
Honored Contributor
Solution

Re: Scripting question

hi,

Quite complex, but using an old script I can propose you this one (not simple but it works ...). Enter a first string and then you can change it (even complete it or use backspaces).

Regards.
It works for me (┬й Bill McNAMARA ...)
Brian M. Fisher
Honored Contributor

Re: Scripting question

Jean-Louis Phelix,

You were correct when you said the script was not simple, but it does exactly what I was looking for.

Thanks for the quick responses,
Brian
<*(((>< er
Perception IS Reality
Fred Martin_1
Valued Contributor

Re: Scripting question

I've attached a script that does what you ask, I think. It's a little strange but hopefully the logic is easy to follow.

Basically it takes the length of the original and the length of the new input, and uses that to create a "prefix" of the numbers that won't change, appending the new numbers to that.

Fred
fmartin@applicatorssales.com
Fred Martin_1
Valued Contributor

Re: Scripting question

With mine, you don't have to backspace...just type the new "suffix"...
fmartin@applicatorssales.com