Вообще, когда создаете file, проще всего ls | sort -n > filename , ну или find . -type f | sort -n > filename.Или так:
#!/bin/bash
filename="$1"
prefix="$2"
postfix="$3"
begin=1
function _go0_exit
{
echo "$1"
exit 1
}
function _go0
{
test -e "$filename" || _go0_exit "Error: content file was not found"
num=$begin
sort -n "$filename" | while read input
do
output="$prefix$num$postfix"
test ! -e "$output" -o -e "input" || continue
echo "[$input] to $output"
mv "$input" "$output"
let num=$num+1
done
}
test $# -ge 3 || _go0_exit "Usage: $0 file prefix postfix"
_go0
exit 0
Тут порядок задания имен в файле не важен.