UPDATED according to changed task.
File file1 with your data created:
for i$ incat file1
1 10 11 12 13 1410 15 1611
10 17 18 19200 201
2 20 21 22 3 420 5 6 721
22 8 9;do echo2000 $i;done|sort
1
10
11
12
13
14
15
16
17
18
19
2
20
21
22
3
4
5
6
7
8
92001
Now we sort the file lines and write results to file2:
for i in 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3$ 4cat 5file1|sort 6-n 7> 8file2
Or we can even simplify it:
sort 9;do-n echofile1 $i;done|sort> -n
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22file2
You can extend numbers with leading zeroes,Checking the results in this cases sort and sort -nfile2 results the same output:
for i$ incat file2
1 10 11 12 13 14 15 16 17 1810 19 11
2 20 21 22 320 4 5 621
10 7 8 9; do200 printf201
22 "%02d\n" $i ;2000 done|sort
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
222001