I have 32 files (named by the same pattern, the only difference is the $sample number as written below) that I want to divide into 4 folders. I am trying to use the following script to do this job, but the script is not working, can someone help me with the following shell script please? - Thanks
#!/bin/bash
max=8 #8 files in each sub folder
numberFolder=4
sample=0
while ($numberFolder > 1) #skip the current folder, as 8 files will remain
do
for (i=1; i<9; i++)
do
$sample= $i * $numberFolder # this distinguish one sample file from another
echo "tophat_"$sample"_ACTTGA_L003_R1_001" //just an echo test, if works, will replace it with "cp".
done
$numberFolder--
end
while (( numberFolder > 1 ))must be written exactly that way, with the double(( )). Same thing for theforloop.(( sample = i * numberFolder )),(( numberFolder-- )). Notably, when you're in a math context, you don't need to use$.