Find a variable in a file and replace its value

HI ,
I can't find a solution to the following:

In a simple menu script I want to capture the input from the user with "read" and use it as a value in a variable Rempages="some_value" which is in a different script file.
So I have to perform a search and replace for this variable and only replace its value.

How can that be done?

The only part that bothers me is the Search and replace the value of the variable. I can use sed to find and replace a matching string but I need to change a value that can be anything between 0 and 99 ( Rempages="number between 0 and 99" ) and I do not know how to make sed do a search of something that can be different every time.

Might be simpler to have a base script that never changes and you create the one you will actully run each time, e.g.

awk 'whatever commands to replace' fixed-base-script > script-ready-to-run

script-ready-to-run

Would that change in logic help?

Robin
Liverpool/Blackburn
UK

Thanks
but short answer is no :slight_smile:
I definitely need command from one script to affect variable value in another one. At least for my task...

Something like this?

#!/bin/bash
read -p "Enter the value : "  val
sed "s/$val/withsomething/g" infile

--ahamed

Yes something like that,
only that withsomething can be different as it is a value from the last input....
So it has to look for a way to identify and replace it