I have hundreds of sub-directories which contain a dollar sign (i.e. "$") as the 1st character in their names, each of which needs to be visited. These sub-directories can not be renamed. The bash script function tries to visit each and (so far) to echo the path its in. Trying to do this via a built path string then eval it
the line that print "cmd=${cmd}" indeed shows "cmd=cd /rbyoko/c/$Ono.RCB" as expected - however, the eval command mis-interprets the $Ono.RCB (probably as $Ono being empty var) and results in: "-bash: cd: /rbyoko/c/.BIN/: No such file or directory" then the following line prints "We are in /home/user" (where the script was run from)
my question: how do I eval the string (and/or escape the sub-directory with "$") to actually succeed in visiting the desired sub-directory ?
Here is my function:
visit_tree_recbin()
{
strings="cdhlotpw"
MACHINE=uname -a
PWD=pwd
for i in $(seq 1 ${#strings})
do
c="${strings:i-1:1}"
echo "Letter $i: $c"
#build eval string to do: cd "/rbyoko/${c}/$Ono.RCB/"
x1="cd /rbyoko/${c}/"
x2="$"
x3="Ono.RCB/"
cmd="${x1}${x2}${x3}"
echo "cmd=${cmd}"
eval "${x1}${x2}${x3}"
echo "We are in " pwd
done
}