Issue
In bash i'd like to read in a variable that is constantly in sync with a files contents.
how can I get this done?
echo "test" > /tmp/test
value=$(</tmp/test)
echo $value
test
echo "test2" > /tmp/test
echo $value
test # Id 'like this to return test2
Solution
As @Fravadona comments, not possible.
Using a function is a workaround:
value() { cat /tmp/test; }
echo "test" > /tmp/test
echo $(value) # => test
echo "test2" > /tmp/test
echo $(value) # => test2
Answered By - glenn jackman Answer Checked By - Candace Johnson (WPSolving Volunteer)