11-08-2011
Sorting data in file based on field in another file
Hi,
I have two files, one of which I would like to sort based on the order of the data in the second. I would like to do this using a simple unix statement.
My two files as follows:
|
File 1: |
12345 1 2 2 2 0 0 |
12349 0 0 2 2 1 2 |
12350 1 2 1 2 2 2 |
. |
. |
. |
I would like to sort the first based on the order of the field in the second file. My output would look like this:
|
Output: |
12350 1 2 1 2 2 2 |
12345 1 2 2 2 0 0 |
12349 0 0 2 2 1 2 |
Many thanks in advance,
Kathryn
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have two comma separated value(CSV) files, say FileA and FileB.
The contents looks like that shown below.
FileA
EmpNo,Name,Age,Sex,
1000,ABC,23,M,
1001,DES,24,F, ... (2 Replies)
Discussion started by: ultimate
2 Replies
2. Shell Programming and Scripting
Hi all,
Sorry the title is a mess, but did not find a better description at the time.
So here is my problem:
I have an input file:
8:Mass40s -- 0
48:Mass40s -- 0
67:Mass40s -- 0
86:Mass40s -- 0
105:Mass40s -- 0
9:Mass -- 1
49:Mass -- 86... (5 Replies)
Discussion started by: Alexis Duarte
5 Replies
3. Shell Programming and Scripting
I have a csv file that I need to extract some data from depending on another field after reading info from another text file.
The text file would say have 592560 in it.
The csv file may have some data like so
Field 1 Field2 Field3 Field4 Field5 Field6
20009756 1 ... (9 Replies)
Discussion started by: GroveTuckey
9 Replies
4. Shell Programming and Scripting
the below is sorted as it is. the fields that i'm interested in are the 4th and 5th field.
i want to sort the based on the 4th field.
my past attempt to do this was to do something like this:
awk '{print $4}'| awk '{print $1":"$2}' datafile | sort | uniq
however, if i do that, i lose... (2 Replies)
Discussion started by: SkySmart
2 Replies
5. Shell Programming and Scripting
Good day all
I need some helps,
say that I have data like below, each field separated by a tab
DATE NAME ADDRESS
15/7/2012 LX a.b.c
15/7/2012 LX1 a.b.c
16/7/2012 AB a.b.c
16/7/2012 AB2 a.b.c
15/7/2012 LX2 a.b.c... (2 Replies)
Discussion started by: alexyyw
2 Replies
6. Shell Programming and Scripting
Hi team,
We have few files landing to our server based on sequence number. These files have to be processed in the sequence number order. Once the sequence number has reached its maximum, the files with sequence number 0000 has to be processed.
For example:
IN9997
IN9998
IN9999
IN0000... (7 Replies)
Discussion started by: anijan
7 Replies
7. Shell Programming and Scripting
Oracle Enterprise Linux 6
This is my file. Two fields separated by space
$ cat testfile.txt
MARCH9 MARCH4
MARCH1 MARCH5
MARCH2 MARCH326
MARCH821 MARCH7
MARCH6 MARCH2
$
$
The following numeric sort, based on the first field's 6th character works as expected.
$
$ sort -n -k 1.6... (7 Replies)
Discussion started by: John K
7 Replies
8. Shell Programming and Scripting
OK below is what my sample file looks like. I need to sort by the Primary Key ie: {1:F01SAESVAV0AXXX0466020126} in the first record. Record seperator is $.
I tried sort, but it completely messes it up. I am thinking I will need to use something like awk which understands the record seperator... (6 Replies)
Discussion started by: alfredo123
6 Replies
9. Shell Programming and Scripting
Hi All
I have a requirement to list all the files in chronological order based on the date value in the file name.For ex if I have three files as given below
ABC_TEST_20160103_1012.txt
ABC_TEST_20160229_1112.txt
ABC_TEST_20160229_1112.txt
I have written code as given below to list out... (2 Replies)
Discussion started by: ginrkf
2 Replies
10. Shell Programming and Scripting
I have two files which are the output of a multiple choice vocab test (60 separate questions) from 104 people (there are some missing responses) and the question list. I have the item list in one file (File1)
Item,Stimulus,Choice1,Choice2,Choice3,Choice4,Correct... (5 Replies)
Discussion started by: samonl
5 Replies
LEARN ABOUT SUSE
slapo-valsort
SLAPO-VALSORT(5) File Formats Manual SLAPO-VALSORT(5)
NAME
slapo-valsort - Value Sorting overlay to slapd
SYNOPSIS
/etc/openldap/slapd.conf
DESCRIPTION
The Value Sorting overlay can be used with a backend database to sort the values of specific multi-valued attributes within a subtree. The
sorting occurs whenever the attributes are returned in a search response.
Sorting can be specified in ascending or descending order, using either numeric or alphanumeric sort methods. Additionally, a "weighted"
sort can be specified, which uses a numeric weight prepended to the attribute values. The weighted sort is always performed in ascending
order, but may be combined with the other methods for values that all have equal weights. The weight is specified by prepending an integer
weight {<weight>} in front of each value of the attribute for which weighted sorting is desired. This weighting factor is stripped off and
never returned in search results.
CONFIGURATION
These slapd.conf options apply to the Value Sorting overlay. They should appear after the overlay directive.
valsort-attr <attribute> <baseDN> (<sort-method> | weighted [<sort-method>])
Configure a sorting method for the specified attribute in the subtree rooted at baseDN. The sort-method may be one of alpha-ascend,
alpha-descend, numeric-ascend, or numeric-descend. If the special weighted method is specified, a secondary sort-method may also be
specified. It is an error to specify an alphanumeric sort-method for an attribute with Integer or NumericString syntax, and it is an
error to specify a numeric sort-method for an attribute with a syntax other than Integer or NumericString.
EXAMPLES
database bdb
suffix dc=example,dc=com
...
overlay valsort
valsort-attr member ou=groups,dc=example,dc=com alpha-ascend
FILES
/etc/openldap/slapd.conf
default slapd configuration file
SEE ALSO
slapd.conf(5), slapd-config(5).
ACKNOWLEDGEMENTS
This module was written in 2005 by Howard Chu of Symas Corporation. The work was sponsored by Stanford University.
OpenLDAP 2.4.21 2009/12/20 SLAPO-VALSORT(5)