//set X to all files of the form proportional.rank
X=$(ls proportional.rank*)
//print out to check X is set
echo $X
//loop over all files of X
for i in $X ; do
before_stem=${i%.ratio_*} //what I want to keep
after_stem=${i#*.ratio_} //what I don't want
new_end =$(printf ".out" $after_stem) //give new ending
mv $i ${before_stem}${new_end} //concatenate the new ending and old beginning
done
%: взять все до шаблона, который следует за знаком фунта%
: взять все после шаблона, который следует за #
printf: точно так же, как C printf
proportional.rank_9.cycle_10157.ratio_9
proportional.rank_9.cycle_10158.ratio_0
proportional.rank_9.cycle_10159.ratio_130
proportional.rank_9.cycle_10160.ratio_7
становится
proportional.rank_9.cycle_10157.out
proportional.rank_9.cycle_10158.out
proportional.rank_9.cycle_10159.out
proportional.rank_9.cycle_10160.out