|
|
1.1 ! root 1: .TI F77/SORT_FILES "Sep. 4, 1985" ! 2: Sorting Data in Files ! 3: ! 4: Sorting of files can be done with the UNIX sort utility, for example: ! 5: ! 6: sort unsrt > srt ! 7: ! 8: sorts the data in file 'unsrt' and writes the sorted records onto file ! 9: \&'srt'. The records are sorted in ascending order using the entire ! 10: record as a sort key. ! 11: ! 12: It is also possible to sort specifying keys by fields. The default is ! 13: that fields are nonblank nonempty strings separated by blanks. For ! 14: example, to sort on the second field separated by blanks (fields separated ! 15: by single blanks): ! 16: ! 17: sort +1 -2 unsrt > srt ! 18: ! 19: You can also specify sorting by specific columns, e.g.: ! 20: ! 21: sort -tx +0.19 -0.29 unsrt > srt ! 22: ! 23: sorts using columns 20-29 as a sort key. 0.19 means to skip 0 fields and ! 24: then skip 19 characters; thus it points at character 20; 0.29 similarly ! 25: points to character 30. +0.19 -0.29 means that the sort key starts in ! 26: column 20 and ends before column 30; i.e. the sort key is columns ! 27: 20-29. The '-tx' forces sort to consider the first column of the ! 28: first field to be in column one, otherwise it considers it to be the ! 29: first nonblank column. ! 30: ! 31: Sorts can be done from within an f77 program by using the ! 32: subroutine system() which causes a UNIX command to be executed. ! 33: For example: ! 34: ! 35: .nf ! 36: open(8,file='unsrt') ! 37: ... code writing data creating unsorted file ... ! 38: close(8) ! 39: call system('sort +0.19 -0.29 unsrt > srt ') ! 40: open(8,file='srt') ! 41: ... code reading sorted data ... ! 42: .fi
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.