I want to read a property file and assign values to variables.
My code was like cat prop_file | while read line ; do value=$line; done
Guess the output I got !!!!
Output: (Nothing) 😦
I and my collegue fought for a looooooooooooooooooooooooong time. Then he asked me to use as follows. Modify the code as:
while read line ; do value=$line; done
and asked it to run as ./myfile.sh prop_file
I got the output.
Reason: After some trials he told me that the reason might be: The cat might spawn a new shell and execute the entire while loop inside the shell. So the value might not persist after the end of while.
And this entry is dedicated to Vaidhy (my collegue) … 🙂 Thanks Vaidhy…