I'm trying to create a script in order to keep the files with the same extension in a folder separated from the rest. In particular, I want a script that, executed in a folder, create soft links of all .tex files and put them in a subfolder "sources".
I know that ln copes well with regular expressions, and $PWD or $(pwd) returns the path to the current folder. So I tried to execute
ln -s $PWD/*.tex ./sources/
in my folder, but soon I realized that in my path there was a folder with spaces in it, that ln reads as multiple files. So I tried with
ln -s '$PWD'/*.tex ./sources/
and
ln -s '$PWD/*.tex' ./sources/
but in both cases, the script produces a single file named *.tex in my sources folder. Following some post, I tried to modify the spaces in the path like these
ln -s $(printf "%q\n" "$PWD")/*.tex sources/
ln -s '$(printf "%q\n" "$PWD")'/*.tex sources/
ln -s '$(printf "%q\n" "$PWD")/*.tex' sources/
but the output was the same (with the difference of an additional character \).
Help?