I want to make a new directory with the name of every zip file currently exists in a specific directory, in another one. I have written a 'for loop' for this purpose:
files=NL*.zip
for a in $files; do
b=echo $a;
sudo mkdir '/home/shokufeh/Desktop/normals/T1/"${b}"';
done
but it creates a directory named ${b} for the first round and make errors for next ones. Could you please tell me what I should do?
b=echo $a;
doesn't do anything at all useful. You're probably thinking of something likeb=$(echo $a)
, but you don't want that either.b=$a
does essentially the same thing, without the potential parsing bugs. But why have a second variable at all, instead of just using$a
directly? – Gordon Davisson Jan 13 '20 at 21:04b=echo $a
would temporarily set the variableb
to the valueecho
and then try to run$a
as a command; so you should get an error message from this line. Since you didn't mention this, I guess that you did not paste your code exactly as you have written it. – user1934428 Jan 14 '20 at 7:20