bash shell
Script syntax weird, written in other languages loop array or list is very simple to achieve, or have the appropriate function to do.
The following two ways to achieve:
method one
c=0
for i in `ls ./Data_Analysis/Quantitation/*-VS-*.xls`;do
pre=`echo $i |sed 's/.*\///'`
filelist[$c]="$pre"
((c++))
done
echo $c
for i in ${filelist[@]}
do
sample=`echo $i | sed 's/.xls//'`
echo $sample
done
Method Two
filelist=()
for i in `ls ./Data_Analysis/Quantitation/*-VS-*.xls`;do
cp $i ./protein
sample=`echo $i |sed 's#.*/##' |sed 's/.xls//'`
filelist+=("$sample")
done
echo ${filelist[@]}
for i in ${filelist[@]};do
echo $i
done