Sponsored Content
Top Forums Shell Programming and Scripting Sorting a file of book records Post 303041848 by Danette on Thursday 5th of December 2019 06:39:05 AM
Old 12-05-2019
Sorting by Year, then sorting by Author Name

Almost everything is going well. However I would like to elaborate a bit more. After I sort in reverse order
I end up with the book listed sorted by year, with most recent on top.



But for records of the same year, I have the author names sorted in reverse as well.


Wnat I would like to have is to sort by year so that the most recent are shown first. But for the same year,
things are sorted by author name alphabetically in order A-Z.

I would not mind adding some form of tag to each record to do this if the command would then be simpler.
As I am using texinfo and build my document using makeinfo, it does not create any problems if I also
add some additional tags to each record, for example on the third line.

Last edited by Danette; 12-05-2019 at 08:11 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count No of Records in File without counting Header and Trailer Records

I have a flat file and need to count no of records in the file less the header and the trailer record. I would appreciate any and all asistance Thanks Hadi Lalani (2 Replies)
Discussion started by: guiguy
2 Replies

2. UNIX for Dummies Questions & Answers

Use records from one file to delete records in another file

file_in_1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 file_in_2: 9 10 11 12 21 22 23 24 1 2 3 4 17 18 19 20 file_out: (5 Replies)
Discussion started by: kenneth.mcbride
5 Replies

3. UNIX for Advanced & Expert Users

Records mismatch while sorting in MPRAS and SunOS

Hi, As part of migrating a script from SunOS to MP RAS, the following script is not functioning in desired way. sort -t\| -u +6 -7 +12 -14 textfile1.out > \ textfile2uniq.out The -u is fetching unique records differently on SunOS and MP RAS Pentium IV. And thus the records... (1 Reply)
Discussion started by: RRVARMA
1 Replies

4. Shell Programming and Scripting

Based on num of records in file1 need to check records in file2 to set some condns

Hi All, I have two files say file1 and file2. I want to check the number of records in file1 and if its atleast 2 (i.e., 2 or greater than 2 ) then I have to check records in file2 .If records in file2 is atleast 1 (i.e. if its not empty ) i have to set some conditions . Could you pls... (3 Replies)
Discussion started by: mavesum
3 Replies

5. Shell Programming and Scripting

Sorting the records in the Flat file

Hi all, I am using this command "sort -d -u -k1 IMSTEST.74E -o tmp.txt" to the records in the flat. Can any tell me how to sort the file except first line in the file For ex: i/p First line: DXYZ Second line : jumy third : cmhk fourth : andy Output should... (5 Replies)
Discussion started by: sudhir_barker
5 Replies

6. Shell Programming and Scripting

Sorting the records for a file

hi, Please suggest me how to do this logic say i am dynamically taking a file name into the script. when ever a file name it should sort the all the records based on the first character in every line except the heading line and ending line. for example file1 heading... (1 Reply)
Discussion started by: angel12345
1 Replies

7. UNIX for Dummies Questions & Answers

Grep specific records from a file of records that are separated by an empty line

Hi everyone. I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this: ID: 20 Name: X Age: 19 ID: 21 Name: Z ID: 22 Email: xxx@yahoo.com Name: Y Age: 19 I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies

8. Shell Programming and Scripting

Deleting duplicate records from file 1 if records from file 2 match

I have 2 files "File 1" is delimited by ";" and "File 2" is delimited by "|". File 1 below (3 record shown): Doc1;03/01/2012;New York;6 Main Street;Mr. Smith 1;Mr. Jones Doc2;03/01/2012;Syracuse;876 Broadway;John Davis;Barbara Lull Doc3;03/01/2012;Buffalo;779 Old Windy Road;Charles... (2 Replies)
Discussion started by: vestport
2 Replies

9. Shell Programming and Scripting

Separate records of a file on 2 types of records

Hi I am new to shell programming in unix Please if I can provide help. I have a file structure of a header record and "N" detail records. The header record will be the total number of detail records I need to split the file in 2: One for the header Another for all detail records Could... (1 Reply)
Discussion started by: jamcogar
1 Replies

10. Shell Programming and Scripting

Sorting group of records and loading last record

Hi Everyone, I have below record set. File is fixed widht file 101newjersyus 20150110 101nboston us 20150103 102boston us 20140106 102boston us 20140103 I need to group record based on first 3 letters in our case(101 and 102) and sort last 8 digit in ascending order and print only... (4 Replies)
Discussion started by: patricjemmy6
4 Replies
sortbib(1)							   User Commands							sortbib(1)

NAME
sortbib - sort a bibliographic database SYNOPSIS
sortbib [-s KEYS] database... DESCRIPTION
sortbib sorts files of records containing refer key-letters by user-specified keys. Records may be separated by blank lines, or by `.[' and `.]' delimiters, but the two styles may not be mixed together. This program reads through each database and pulls out key fields, which are sorted separately. The sorted key fields contain the file pointer, byte offset, and length of corresponding records. These records are delivered using disk seeks and reads, so sortbib may not be used in a pipeline to read standard input. The most common key-letters and their meanings are given below. %A Author's name %B Book containing article referenced %C City (place of publication) %D Date of publication %E Editor of book containing article referenced %F Footnote number or label (supplied by refer) %G Government order number %H Header commentary, printed before reference %I Issuer (publisher) %J Journal containing article %K Keywords to use in locating reference %L Label field used by -k option of refer %M Bell Labs Memorandum (undefined) %N Number within volume %O Other commentary, printed at end of reference %P Page number(s) %Q Corporate or Foreign Author (unreversed) %R Report, paper, or thesis (unpublished) %S Series title %T Title of article or book %V Volume number %X Abstract -- used by roffbib, not by refer %Y,Z Ignored by refer By default, sortbib alphabetizes by the first %A and the %D fields, which contain the senior author and date. sortbib sorts on the last word on the %A line, which is assumed to be the author's last name. A word in the final position, such as `jr.' or `ed.', will be ignored if the name beforehand ends with a comma. Authors with two-word last names or unusual constructions can be sorted correctly by using the nroff convention `' in place of a blank. A %Q field is considered to be the same as %A, except sorting begins with the first, not the last, word. sortbib sorts on the last word of the %D line, usually the year. It also ignores leading articles (like `A' or `The') when sorting by titles in the %T or %J fields; it will ignore articles of any modern European language. If a sort-significant field is absent from a record, sortbib places that record before other records containing that field. No more than 16 databases may be sorted together at one time. Records longer than 4096 characters will be truncated. OPTIONS
-sKEYS Specify new KEYS. For instance, -sATD will sort by author, title, and date, while -sA+D will sort by all authors, and date. Sort keys past the fourth are not meaningful. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWdoc | +-----------------------------+-----------------------------+ SEE ALSO
addbib(1), indxbib(1), lookbib(1), refer(1), roffbib(1), attributes(5) BUGS
Records with missing author fields should probably be sorted by title. SunOS 5.10 14 Sep 1992 sortbib(1)
All times are GMT -4. The time now is 04:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy