I need to use *.* at the end of a Path that is stored in a variable. Also just one "*" should be OK as well.
finally I want to move files in folders with same name. With a static Path like /share/test/temp/* the for loop worked.
Now I have different usernames and the search folder for the for loop changes. Therefore I need a varible there.
This doesnt work:
destDir= $Startdir/$username/
a=$destDir/*.*
for file in $a ; do
tmp=${file:0:4};
filenew=${file%.*}"($tmp)";
mkdir -- "$filenew";
mv -- "$file" "$filenew";
done
I have tried to escape, single and double marks and backticks.
a=$destDir/*.* # not working
a="$destDir/\*" # not working
a= $destDir'/\*' # not working
a="$destDir/'\*.\*" # not working
How can I make a pure sting with asterix in it, that will be substitued in the for loop? Or is there any other option to pass a variable to a for loop that stores a path and for knows that he has to search very file in that path?
I would perfer a for loop than find $destDir -name ..
=in an assignment -- that changes their meaning completely.destDir="$Startdir/$username"for file in "$destDir"/*.* ; do ...for file in $destDir/*.*; do tmp=$"{file:0:4}"; filenew="${file%.*}""($tmp)"; mkdir -- "$filenew"; mv -- "$file" "$filenew"; donedestDir= 'share/temp/test' ; destDir=$Startdir/$username/ ; a="$destDir/*.*" ; echo $a ;How Can I use Asterix or "." in bash in a variable?var= something, the space breaks the syntax, so your example doesn't make sense. And we need to know if you want*(all files) or*.*(all files whose name contains a.).