I receive files which names contain spaces and change every week (the name contains the week number)
IE, the file for this week looks like This is the file - w
Use a bash array
v=( /dir/This\ is\ the\ file - w*.csv )
If there is guaranteed to be only one matching file, you can just expand $v
. Otherwise, you can get the full list of matching files by expanding as
"${v[@]}"
or individual matches using
"${v[0]", "${v[1]}", etc
echo /dir/"This is the file - w"*.csv
or — you almost tried that —
echo /dir/This\ is\ the\ file\ -\ w*.csv
First of all, you should not use the dollar sign in an assignment.
Moreover, wildcard expansion is not called in an assignment. You can use process substitution for example, though:
FILE=$(echo 'This is the file - w'*.csv)
Note that the wildcard itself is not included in the quotes. Quotes prevent wildcard expansion.