Как расположить в порядке возрастания слева направо в vi или с помощью команды sort ?
Образец до аранжировки:
2  3
3  6
5  1
4  2
5  8
Я хочу это таким образом:
2  3
3  6
1  5
2  4
5  8
 Это может быть одна строка с помощью следующей команды:
while read p;do echo $p|tr ' ' '\n'|sort -k1|paste -s -d' ' -;done<input>output
Замените ввод и вывод вашими фактическими файлами ввода-вывода.
Я написал небольшой скрипт, который также можно использовать для проверки этого:
#!/bin/bash
# This script is just for testing purposes. 
# Call this like:
#   sort_numbers numbers.txt numbers_correct.txt
# Where numbers.txt is the file to sort and
# numbers_correct.txt is a file where they are 
# sorted correct.
while read p; do 
  echo $p|tr ' ' '\n'|sort -k1|paste -s -d' ' -
done<$1>output.$1
# This just compares the output with the correct output
file1=$2
file2=output.$1
echo -n $file1 and $file2 are' ' && cmp --silent $file1 $file2 && echo the same || echo different