Sponsored Content
Full Discussion: sort script
Top Forums Shell Programming and Scripting sort script Post 302713501 by Don Cragun on Wednesday 10th of October 2012 10:07:02 PM
Old 10-10-2012
Unless you will know from the header name how a field should be sorted (forward or reverse, numeric or alphanumeric, etc.), you will probably need some manual intervention. If you just want to use header names instead of field numbers but can otherwise use the sort utility's flags to control the type of sorting to be done, we can probably help you come up with a way to do that if you give us some concrete examples of what your data looks like (including the headers). Please use code tags when you post this information; knowing whether fields are separated by <space>s, <tab>s, <colon>s, <comma>s or something else will be crucial to coming up with a working solution.

You are correct in noting that some versions of awk provide built-in sorting functions, but they are not portable and (as far as I know) limited to increasing order alphanumeric sorting.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort utility in script ?

Hi friends, I want to use sort command in script. I used the following syntax in my scipt, sort -t '|' +3 tempcdrext4.cdr > temp.mocdr It give me a error " Input file specified two times." but this command work fine in the prompt without any problem. Can sombody please tell me who... (2 Replies)
Discussion started by: maheshsri
2 Replies

2. UNIX for Dummies Questions & Answers

sort script/command

ok. i am doing a project where i have hand typed in the titles of nearly 500 DVD titles, each one is on a seperate line. but they arent in any type of alphebetical order, and i need them sorted in that format (A-Z or a-z) ..... i know that the 'sort' command can be used but also know the... (6 Replies)
Discussion started by: Chadbot
6 Replies

3. Shell Programming and Scripting

Script to sort data

Hi All, I have a .csv file with 3 columns called nLats, nLongs, and fRes. in following format : "nLats","nLongs","fRes" 0,0,-1 0,1,-1 0,2,-1 0,3,-1 0,4,-1 ......... ......... 0,143,-1 nLats increments at nLongs=143 1,0, -1 1,1, -1 .......... .......... 1,143,-1... (1 Reply)
Discussion started by: wizardy_maximus
1 Replies

4. Shell Programming and Scripting

Using sort with awk script

I have a file with four fields and an awk script that strips out one field displaying the remaining three. I have added headings for each of these fields such as Player - Year - RBIs then below it comes the data. What I am trying to do is sort the RBIs field in my script from most to least at the... (9 Replies)
Discussion started by: Trellot
9 Replies

5. Shell Programming and Scripting

need Unix script to sort

Hi i have a file like this oprvdw vrc002093j.ksh oprvdw vrc002092j.ksh oprvrc vrc045016j.ksh oprvrc vrc055141j.ksh svemietl bdw0231185.sh svemietl bdw0231145.sh and i need a script which dispalys in below format: oprvdw : vrc002093j.ksh vrc002092j.ksh oprvrc :... (0 Replies)
Discussion started by: p_satyambabu
0 Replies

6. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

7. UNIX for Dummies Questions & Answers

sort script

hi guys i looking for someone to help me with a script i want to sort all de files from /bin by size (from max to min) and the size and path of first 3 files to be written in /home/user/bin_size .And i want to put that script in crontab to execute every monday at 20:00 Can someone help me... (2 Replies)
Discussion started by: G30
2 Replies

8. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

9. Shell Programming and Scripting

Script to Sort into columns

Hi geeks! I want to convert the following: EPC-NotificationData: sms:2348034503643 EPC-GroupIds: 300H:10:22-01-2014T07:30:14,22-04-2014T07:30:14 To: EPC-NotificationData: sms:2348034503643, EPC-GroupIds: 300H:10:22-01-2014T07:30:14,22-04-2014T07:30:14 I want them to be on the same... (13 Replies)
Discussion started by: infinitydon
13 Replies

10. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies
Prima::DetailedList(3)					User Contributed Perl Documentation				    Prima::DetailedList(3)

NAME
Prima::DetailedList - a multi-column list viewer with controlling header widget. SYNOPSIS
use Prima::DetailedList; my $l = $w-> insert( 'Prima::DetailedList', columns => 2, headers => [ 'Column 1', 'Column 2' ], items => [ ['Row 1, Col 1', 'Row 1, Col 2'], ['Row 2, Col 1', 'Row 2, Col 2'] ], ); $l-> sort(1); DESCRIPTION
Prima::DetailedList is a descendant of Prima::ListViewer, and as such provides a certain level of abstraction. It overloads format of items in order to support multi-column ( 2D ) cell span. It also inserts Prima::Header widget on top of the list, so the user can interactively move, resize and sort the content of the list. The sorting mechanism is realized inside the package; it is activated by the mouse click on a header tab. Since the class inherits Prima::ListViewer, some functionality, like 'item search by key', or "get_item_text" method can not operate on 2D lists. Therefore, mainColumn property is introduced, that selects the column representing all the data. API
Events Sort COLUMN, DIRECTION Called inside sort method, to facilitate custom algorithms of sorting. If the callback procedure is willing to sort by COLUMN index, then it must call "clear_event", to signal the event flow stop. The DIRECTION is a boolean flag, specifying whether the sorting must be performed is ascending ( 1 ) or descending ( 0 ) order. The callback procedure must operate on the internal storage of "{items}", which is an array of arrays of scalars. The default action is the literal sorting algorithm, where precedence is arbitrated by "cmp" operator ( see "Equality Operators" in perlop ) . Properties columns INTEGER Governs the number of columns in items. If set-called, and the new number is different from the old number, both items and headers are restructured. Default value: 0 headerClass Assigns a header class. Create-only property. Default value: "Prima::Header" headerProfile HASH Assigns hash of properties, passed to the header widget during the creation. Create-only property. headerDelegations ARRAY Assigns a header widget list of delegated notifications. Create-only property. headers ARRAY Array of strings, passed to the header widget as column titles. items ARRAY Array of arrays of scalars, of arbitrary kind. The default behavior, however, assumes that the scalars are strings. The data direction is from left to right and from top to bottom. mainColumn INTEGER Selects the column, responsible for representation of all the data. As the user clicks the header tab, "mainColumn" is automatically changed to the corresponding column. Default value: 0 Methods sort [ COLUMN ] Sorts items by the COLUMN index in ascending order. If COLUMN is not specified, sorts by the last specified column, or by #0 if it is the first "sort" invocation. If COLUMN was specified, and the last specified column equals to COLUMN, the sort direction is reversed. The method does not perform sorting itself, but invokes Sort notification, so the sorting algorithms can be overloaded, or be applied differently to the columns. AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>. SEE ALSO
Prima, Prima::Lists, Prima::Header, examples/sheet.pl perl v5.14.2 2009-02-24 Prima::DetailedList(3)
All times are GMT -4. The time now is 02:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy