how can I assign a dynamic value to variable? The simplest method I know about is by using a function. For example
fn(){
VAR=$VAL
}
VAL=value
fn
echo $VAR
will output
value
but I want something simpler, like
VAR=$VAL
VAL=value
echo $VAR
to output
value
What command should I use? Preferably to be compatible with dash.
Thanks!
UPDATE: Removed #!/bin/sh in connection to dash. Thank "Ignacio Vazquez-Abrams" for the explanation!
UPDATE 2: Adding the source for my script to better understand the situation.
INPUT=`dpkg -l|grep ^rc|cut -d' ' -f3`
filter(){
echo *$A*
}
for A in $INPUT;do find ~ -iname `filter`|grep ^$HOME/\\.|grep -iz --color $A;done
This script should help finding the remaining configuration files of removed packages.
How about a simple function that sets value?
The code above will display: