04-02-2009
Sorry, I will try to explain more detailed
the intersection is all lines that have the numbers in the column A equal.
I will compare lines from set1 to set2, but just using the members of column A.
something like this
FOR each lines OF set1
FOR each line of set2
if first member of this line (columnA) of set1 == first member of the line of setB
print line set1 + of setB
end IF
end FOR
end FOR
So if I have
set1
columns A B C
first line 7 9 10
second line 8 10 12
set2
columns A D E
first line 6 9 10
second line 8 13 12
I will compare all lines of this two sets and look for lines that have the equal A, when I find the equal A, print this line of set1 + set2.
It is better now? Sorry for the english, it is my second language.
Last edited by alcalina; 04-02-2009 at 11:46 AM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have one situation. I have some 6-7 no. of files in one directory & I have to extract all the lines which exist in all these files. means I need to extract all common lines from all these files & put them in a separate file.
Please help. I know it could be done with the help of... (11 Replies)
Discussion started by: The Observer
11 Replies
2. Ubuntu
Dear All,
I am new to this forum and please ignore my little knowledge :p
I have two types of data (a subset is given below)
data version 1:
439798 2 1
451209 1 2
508696 2 1
555760 2 1
582757 1 2
582889 1 2
691827... (2 Replies)
Discussion started by: evoll
2 Replies
3. Shell Programming and Scripting
Hi Friends,
I am new to Shell Scripting and need your help in the below situation.
- I have two files (File 1 and File 2) and the contents of the files are mentioned below.
- "Application handle" is the common field in both the files.
(NOTE :- PLEASE REFER TO THE ATTACHMENT "Compare files... (2 Replies)
Discussion started by: Santoshbn
2 Replies
4. Shell Programming and Scripting
Hi
I have two sample files attached here
one file contain entries in one column and second file contains entries in many columns
I have to match entries of first file with entries in secon d file form secon column onwards and if matches write "match" in front of it.
I tried several... (11 Replies)
Discussion started by: manigrover
11 Replies
5. Shell Programming and Scripting
Hi All,
I have 4 files in below format. I took them as an example.
File 1: Cut from position 1-4 then 6-7 then 8-14 then rest left and make them as columns in one new file. Inserting character H to the initial of all line like HCTOT.
CTOT 456787897 Low fever
CTOR 556712345 High fever... (2 Replies)
Discussion started by: Mannu2525
2 Replies
6. Shell Programming and Scripting
Hi,
I am new to Unix and I am finding it hard to fix a particular logic.
The context is as below.
File 1 :
This contains of 5 fields :
Type | Bank Code | Account | Name | Date/Time
60|ABC123|TX123456|XXXX|YYYYMMDDHH:MM:SS
72|ABC123|MYD34561|XXXX|YYYYMMDDHH:MM:SS... (4 Replies)
Discussion started by: DJose
4 Replies
7. Shell Programming and Scripting
Hello Unix gurus,
I have a file with this format (example values):
label1 1 0
label2 1 0
label3 0.4 0.6
label4 0.5 0.5
label5 0.1 0.9
label6 0.9 0.1
in which:
column 1 is a row label
column 2 and 3 are values
I would like to do a simple operation on this table and get the... (8 Replies)
Discussion started by: ksennin
8 Replies
8. Shell Programming and Scripting
Hi all,
I've multiple files. In this case 5. Space separated columns. Each file has 12 columns. Each file has 300-400K lines.
I want to get the output such that if a value in column 2 is present in all the files then get all the columns of that value and print it side by side.
Desired output... (15 Replies)
Discussion started by: genome
15 Replies
9. UNIX for Beginners Questions & Answers
Hello,
I am new to Unix and would like to seek a help, please.
I have 2 files (file_1 and file_2), I need to perform the following actions.
1 ) Sort the both file by the column 26-36 (which is Invoice number)
what is sort command with the column sort?
2) Compare the file_1.sorted and... (3 Replies)
Discussion started by: Usagi
3 Replies
10. Shell Programming and Scripting
Hello,
I have a file with 2 columns ( tableName , ColumnName) delimited by a Pipe like below . File is sorted by ColumnName.
Table1|Column1
Table2|Column1
Table5|Column1
Table3|Column2
Table2|Column2
Table4|Column3
Table2|Column3
Table2|Column4
Table5|Column4
Table2|Column5
From... (6 Replies)
Discussion started by: nv186000
6 Replies
LEARN ABOUT DEBIAN
af_nrofkeys
af_sets(3) Attribute Filesystem (AtFS) af_sets(3)
NAME
af_initset, af_nrofkeys, af_setgkey, af_setaddkey, af_setrmkey, af_setposrmkey, af_sortset, af_subset, af_copyset, af_intersect, af_union,
af_diff - AtFS operations on key sets
SYNOPSIS
#include <atfs.h>
int af_initset (Af_set *set)
int af_nrofkeys (Af_set *set)
int af_setgkey (Af_set *set, int position, Af_key *key)
int af_setaddkey (Af_set *set, int position, Af_key *key)
int af_setrmkey (Af_set *set, Af_key *key)
int af_setposrmkey (Af_set *set, int position)
int af_sortset (Af_set *set, char *attrname)
int af_subset (Af_set *set, Af_attrs *attrbuf, Af_set *subset)
int af_copyset (Af_set *source, Af_set *destination)
int af_intersect (Af_set *set1, Af_set *set2, Af_set *newset)
int af_union (Af_set *set1, Af_set *set2, Af_set *newset)
int af_diff (Af_set *set1, Af_set *set2, *Af_set newset)
DESCRIPTION
Sets in AtFS are ordered collections of keys. The structure of sets is the following
typedef struct {
int af_nkeys;
int af_setlen;
Af_key *af_klist;
} Af_set;
The list of keys in a set is a linear list, residing in allocated memory. The list has no holes, so that positions 0 through af_nkeys-1 are
occupied with valid keys. Set functions returning a set require a pointer to an empty set structure as argument.
af_initset initializes a set.
af_nrofkeys returns the number of valid keys in the given set.
af_setgkey delivers the filekey, stored at position position in the identified set. The result is passed in the buffer key. Typically you
use af_setgkey to run through a set and perform a special action on each key. The following code sequence does this job:
Af_key key;
Af_set set;
af_initset (&set);
...
for (i = 0; i < af_nrofkeys (&set); i++) {
af_setgkey (&set, i, &key);
/* process key */
...
}
af_setaddkey introduces a new filekey to an existing set at the given position. All following keys are moved back by one position. The
constant AF_LASTPOS given as position argument leads to adding the new filekey at the end of the set.
af_setrmkey (af_setposrmkey) removes the given filekey (the filekey at position position) from the specified set. Holes generated by delet-
ing single keys from a set are eliminated by condensing the set. All following keys are moved one position forth in the set.
af_sortset sorts a given set of object keys by the values of the named attribute. The set is sorted in increasing order. Increasing order
means, that the lowest value occurs first in the set. Af_user structures are compared by username first and by userdomain, if the names
are equal (user host will not be taken into account). Version numbers are ordered in natural order, busy versions first.
In atfs.h you can find a list of attribute names naming the standard attributes. All other attribute names are presumed to be user defined
attributes. While sorting by the values of an user defined attribute, all ASOs that do not have the named attribute are added at the end of
the resulting (sorted) set. Sorting of user defined attributes with multiple values bases on simple text comparison with the order of the
values taken as it is. The length of the given attribute name is limited. This limit is defined by the constant AF_UDANAMLEN in atfs.h.
af_subset does a retrieve operation (similar to af_find - manual page af_retrieve(3)) on a given set of object keys. Af_subset takes an
attribute buffer (attrbuf) with all desired attributes set to an appropriate value as argument. The attribute buffer should be initialized
by af_initattrs (manual page af_retrieve(3)) beforehand. af_subset returns it's result in a new set, the original set remains unchanged.
af_copyset for copying sets (really! =:-).
af_intersect, af_union and af_diff build intersections, unions, and differences between two sets. The result is a new set, where all keys
taken from the first argument set (set1) occur first, and the keys from the second argument set (set2) afterwards. You may gibe one of set1
or set2 as resultset. In that case, the original set get lost and is dropped implicitely.
Sets generated by af_copyset, af_subset, af_intersect, af_union, or af_diff should be released by af_dropset as soon as they are not used
any longer.
SEE ALSO
af_retrieve(3)
DIAGNOSTICS
Upon error, -1 or a nil pointer (depending on the return type) is returned and af_errno is set to the corresponding error number.
AtFS-1.71 Fri Jun 25 14:33:20 1993 af_sets(3)