0

I have a config file something like below.

_ispip=$_octet.129
_octet=10.89.2
_rxpip=$_octet.132

And when i try to echo the value its not printing the full values for the 1st variable. Is there a easy way to fix this?

# source test.cfg
# echo $_ispip
.129

# echo $_octet
10.89.2

# echo $_rxpip
10.89.2.132
0

1 Answer 1

1

bash doesn't have lazy evaluation, it will try to replace $_octet when you refer to it. If you do this before the assignment, you get an empty string.

You need to put the _octet assignment before _ispip.

_octet=10.89.2
_ispip=$_octet.129
_rxpip=$_octet.132
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your response. My configuration file as 1000+ lines. Using the source command its loading the variables to memory and using it when needed. So rearranging the values is kind a tough job here. Any other ways you recommend?
@SandoshKumarP Automate rearranging the values ;)
@SandoshKumarP How many of the variables are referenced in other variables? You only need to rearrange those variables, put them all at the top.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.