Sponsored Content
Full Discussion: sort columns by field
Top Forums Shell Programming and Scripting sort columns by field Post 302168802 by jim mcnamara on Tuesday 19th of February 2008 01:26:32 PM
Old 02-19-2008
Code:
head -1 table > workingfile
awk 'NR>1' table | sort -k1.1,1.10 -k2.1,2.10 -k 23.1,3.10  | \
    awk '!arr[$2 $3]++' >> workingfile

remove duplicates on col2 and col 3.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sort by Columns

Hello, I am new in UNIX I am looking for a instrction to sort a file by columns 6,25 and 41 this is what I tried but not getting the correct result: sort -t= -k1.6,1.25,1.41 to_sort.txt > sorted.txt I used -t= just to get the whole line as one field. INVS80993596SUM994338602XX... (1 Reply)
Discussion started by: murbina
1 Replies

2. UNIX for Dummies Questions & Answers

Sort - only one field appears in output?

I'm running against a file with 1008 records like this, all beginning '4760 Slave': 4760 Slave,7,3607 ,GL ,200605,11320024 , ,GBP ,X00033 ,AI80190 ... (1 Reply)
Discussion started by: miwinter
1 Replies

3. Shell Programming and Scripting

Sort alpha on 1st field, numerical on 2nd field (sci notation)

I want to sort alphabetically on the first field and sort in descending numerical order on the 2nd field. With a normal "sort -r -n" it does this: abc ||| 5e-05 ||| bla abc ||| 3 ||| ble def ||| 1 ||| abc def ||| 0.2 ||| def As you can see it ignores the fact that 5e-05 is actually 0.00005... (1 Reply)
Discussion started by: FrancoisCN
1 Replies

4. Shell Programming and Scripting

Sort two columns in a field, one of them being a date

Hi, I have a set of columns in a csv file, my first row being an integer and 2nd being a date. I want to first sort it using the first column and then by the second. for e.g. i have , 1234,09/05/2009,hi 5678,01/01/2008,hi 1234,11/03/2006,hello 5678,28/07/2010,hello i tried this... (5 Replies)
Discussion started by: sweta_doshi
5 Replies

5. UNIX for Advanced & Expert Users

Sort on basis of particular field

05.50.25:AIRE.S:RESTRICTED:S2: 05.50.25:ANDR.VI:RESTRICTED:S2: 05.50.25:BASF.MI:RESTRICTED:N: 05.50.25:BMWG.DE:RESTRICTED:N: 05.50.25:BORE.ST:RESTRICTED:N: I can sort of the basis of second field using " sort -t: -k2,2 " but what i want to sort the data is on the basis its extension e.g.:... (9 Replies)
Discussion started by: manishma71
9 Replies

6. Shell Programming and Scripting

Sort help on non numeric field

Hi, I am unable to sort data on the first field $cat t Jim,212121,Seattle Bill,404404,Seattle Steve,246810,Nevada Scott,212277,LosAngeles Jim,212121,Ohio sort -t"," -k1,2 t Bill,404404,Seattle Jim,212121,Ohio Jim,212121,Seattle Scott,212277,LosAngeles Steve,246810,Nevada (7 Replies)
Discussion started by: Shivdatta
7 Replies

7. UNIX for Dummies Questions & Answers

Sort by columns

Hello, I have a text file that looks like this and I need a bash script to: 12:48:32 PM 002* OUT 000418 01:10:34 PM 002* ONL 000418 01:49:17 PM 001* OUT 000364 01:52:09 PM 001* ONL 000364 ... The fields are: 12-hour format time, some number, state (online, offline) and another... (2 Replies)
Discussion started by: Ravendark
2 Replies

8. Shell Programming and Scripting

Sorting Date Field with Sort -k :/

SOLVED : (17 Replies)
Discussion started by: Glitch100
17 Replies

9. Shell Programming and Scripting

Sort field and uniq

I have a flatfile A.txt 2012/12/04 14:06:07 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 17:07:22 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 17:13:27 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 14:07:39 |rain|Boards 1|tampa|merced|merced11 How do i sort and get... (3 Replies)
Discussion started by: sabercats
3 Replies

10. UNIX for Dummies Questions & Answers

UNIX Sort on a field that spans multiple columns

New to unix. I need to sort the records of a file by a control number field. That field is in POS 16 through 28. How do I do that? There are no delimiters, or spaces to separate fields. See example below. Each line is a record. REC1CCYYMMDD0018888888888888ABCDE... (1 Reply)
Discussion started by: jclanc8
1 Replies
griffith(1)															       griffith(1)

NAME
griffith - film collection manager SYNOPSIS
griffith DESCRIPTION
Griffith is a film collection manager. Adding items to the movie collection is as quick and easy as typing the film title and selecting a supported source. Griffith will then try to fetch all the related information from the Web. OPTIONS
-h --help Show usage information. -D --debug Run in debug mode. -C --clean find and delete orphan files in posters directory. --check-dep check dependencies - if all needed Python modules are installed, it prints nothting. --sqlecho Prints all SQL queries to standard output. --home DIR Set Griffith's home directory. Use this option if you want to change the default ~/.griffith Printing movie list: -c <expr> --cast=<expr> cast field must contain <expr> -d <expr> --director=<expr> director field must contain <expr> -o <expr> --original_title=<expr> original title field must contain <expr> -t <expr> --title=<expr> title field must contain <expr> -y <number> --year=<number> movie must be released in year <number> -s <columns> --sort=<columns> set sort columns to <columns>. Example: --sort=o_title,number,director SEE ALSO
Homepage: <http://www.griffith.cc/> BUGS
If you want to help or report any bugs founded please visit homepage <http://www.griffith.cc/> or <https://bugs.launchpad.net/griffith> AUTHORS
Griffith was written by Vasco Nunes and Piotr OA1/4arowski. See the AUTHORS and THANKS files for a list of other contributors. Copyright (C) 2005-2008 Vasco Nunes <vasco.m.nunes@gmail.com>, Piotr OA1/4arowski <ozarow+griffith@gmail.com>, This man page was written by Piotr Ozarowski Dec 20, 2006 griffith(1)
All times are GMT -4. The time now is 12:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy