История изменений
Исправление LinuxUser, (текущая версия) :
if [ "`head -c 1 input_file`" != '/' ]; then
echo Error: wrong file format'' 1>&2
exit 1
fi
i=0
while read sections[$i] && read -r -d / lines[$i]; do
((i++))
done < <(tail -c +2 input_file; echo /)
echo -n > output_file
for i in `seq 0 $((${#sections[*]} - 2))`; do
(echo "/${sections[$i]}"; echo "${lines[$i]}" | sort) >> output_file
done
Исходная версия LinuxUser, :
if [ "`head -c 1 input_file`" != '/' ]; then
echo Error: wrong file format'' 1>&2
exit 1
fi
i=0
while read sections[$i] && read -r -d / lines[$i]; do
((i++))
done < <(tail -c +2 input_file; echo /)
echo -n > output_file
for i in `seq 0 $((${#sections[*]} - 2))`; do
(echo "/${sections[$i]}"; echo "${lines[$i]}" | sort) >> output_file; done