06-19-2012
Great!
Aha, you were absolutely correct! I apologize, as I did have a formatting issue in the first column of the test files. Once I fixed that, the awk command works perfectly. Really amazing stuff, and thanks so much again!
mbp
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello!
I am writing a program to run through two large lists of data (~300,000 rows), find where rows in one file match another, and combine them based on matching fields. Due to the large file sizes, I'm guessing AWK will be the most efficient way to do this. Overall, the input and output I'm... (5 Replies)
Discussion started by: Michelangelo
5 Replies
2. Shell Programming and Scripting
I am newbie to unix and would please like some help to solve the task below
I have two files, file_a.text and file_b.text that I want to evaluate.
file_a.text
1698.74
1711.88
6576.25
899.41
3205.63
4187.98
697.35
1551.83 ... (3 Replies)
Discussion started by: gameli
3 Replies
3. Shell Programming and Scripting
Hi,
Please excuse for often requesting queries and making R&D, I am trying to work out a possibility where i have two files field separated by pipe and another file containing only one field where there is no matching columns, Could you please advise how to merge two files.
$more... (3 Replies)
Discussion started by: karthikram
3 Replies
4. Shell Programming and Scripting
Hi everyone,
Given two files (test1 and test2) with the following contents:
test1:
80263760,I71
80267369,M44
80274628,L77
80276793,I32
80277390,K05
80277391,I06
80279206,I43
80279859,K37
80279866,K35
80279867,J16
80280346,I14and test2:
80263760,PT18
80279867,PT01I need to do some... (3 Replies)
Discussion started by: gacanepa
3 Replies
5. UNIX for Beginners Questions & Answers
Hi,
I have 2 tab-delimited input files as follows.
file1.tab:
green A apple
red B apple
file2.tab:
apple - A;Z
Objective:
Return $1 of file1 if,
. $1 of file2 matches $3 of file1 and,
. any single element (separated by ";") in $3 of file2 is present in $2 of file1
In order to... (3 Replies)
Discussion started by: beca123456
3 Replies
6. Shell Programming and Scripting
Trying to use awk to match the contents of each line in file1 with $5 in file2. Both files are tab-delimited and there may be a space or special character in the name being matched in file2, for example in file1 the name is BRCA1 but in file2 the name is BRCA 1 or in file1 name is BCR but in file2... (6 Replies)
Discussion started by: cmccabe
6 Replies
7. UNIX for Beginners Questions & Answers
In two previous posts (here) and (here), I received help from forum members comparing multiple fields across two files and selectively printing portions of each as output based upon would-be matches using awk. I had been fairly comfortable populating awk arrays with fields and using awk's special... (3 Replies)
Discussion started by: jvoot
3 Replies
8. Shell Programming and Scripting
I am trying to parse two csv files and make a match in one column then print the entire file to a new file and append an additional column that gives description from the match to the new file. If a match is not made, I would like to add "NA" to the end of the file
Command that Ive been using... (6 Replies)
Discussion started by: dis0wned
6 Replies
9. Shell Programming and Scripting
Long time listener first time poster. Hope someone can advise.
I have two files, 1000+ lines in each, two fields in each file.
After performing a sort, what is the best way to find exact matches where field $1 and $2 in file1 are also present in file2 on the same line, then output only those... (6 Replies)
Discussion started by: bstaff
6 Replies
10. UNIX for Beginners Questions & Answers
Hello all, I am having trouble with what should be an easy task, but seem to be missing something fundamental. I have two files, with File 1 consisting of a single field of many thousands of records. I also have File 2 with two fields and many thousands of records.
My goal is that when $1 of... (2 Replies)
Discussion started by: jvoot
2 Replies
LEARN ABOUT DEBIAN
mb_put_mem
MBCHAIN(9) BSD Kernel Developer's Manual MBCHAIN(9)
NAME
mbchain, mb_init, mb_initm, mb_done, mb_detach, mb_fixhdr, mb_reserve, mb_put_uint8, mb_put_uint16be, mb_put_uint16le, mb_put_uint32be,
mb_put_uint32le, mb_put_int64be, mb_put_int64le, mb_put_mem, mb_put_mbuf, mb_put_uio -- set of functions to build an mbuf chain from various
data types
SYNOPSIS
options LIBMCHAIN
kldload libmchain
#include <sys/param.h>
#include <sys/uio.h>
#include <sys/mchain.h>
int
mb_init(struct mbchain *mbp);
void
mb_initm(struct mbchain *mbp, struct mbuf *m);
void
mb_done(struct mbchain *mbp);
struct mbuf *
mb_detach(struct mbchain *mbp);
int
mb_fixhdr(struct mbchain *mbp);
caddr_t
mb_reserve(struct mbchain *mbp, int size);
int
mb_put_uint8(struct mbchain *mbp, u_int8_t x);
int
mb_put_uint16be(struct mbchain *mbp, u_int16_t x);
int
mb_put_uint16le(struct mbchain *mbp, u_int16_t x);
int
mb_put_uint32be(struct mbchain *mbp, u_int32_t x);
int
mb_put_uint32le(struct mbchain *mbp, u_int32_t x);
int
mb_put_int64be(struct mbchain *mbp, int64_t x);
int
mb_put_int64le(struct mbchain *mbp, int64_t x);
int
mb_put_mem(struct mbchain *mbp, c_caddr_t source, int size, int type);
int
mb_put_mbuf(struct mbchain *mbp, struct mbuf *m);
int
mb_put_uio(struct mbchain *mbp, struct uio *uiop, int size);
DESCRIPTION
These functions are used to compose mbuf chains from various data types. The mbchain structure is used as a working context and should be
initialized with a call to either mb_init() or mb_initm(). It has the following fields:
mb_top (struct mbuf *) A pointer to the top of constructed mbuf chain.
mb_cur (struct mbuf *) A pointer to the currently filled mbuf.
mb_mleft (int) Number of bytes left in the current mbuf.
mb_count (int) Total number of bytes placed in the mbuf chain.
mb_copy (mb_copy_t *) User-defined function to perform a copy into mbuf; useful if any unusual data conversion is necessary.
mb_udata (void *) User-supplied data which can be used in the mb_copy function.
mb_done() function disposes an mbuf chain pointed to by mbp->mb_top field and sets the field to NULL.
mb_detach() function returns the value of mbp->mb_top field and sets its value to NULL.
mb_fixhdr() recalculates the length of an mbuf chain and updates the m_pkthdr.len field of the first mbuf in the chain. It returns the cal-
culated length.
mb_reserve() ensures that the object of the length specified by the size argument will fit in the current mbuf (mbuf allocation is performed
if necessary), and advances all pointers as if the real data was placed. Returned value will point to the beginning of the reserved space.
Note that the size of the object should not exceed MLEN bytes.
All mb_put_*() functions perform an actual copy of the data into mbuf chain. Functions which have le or be suffixes will perform conversion
to the little- or big-endian data formats.
mb_put_mem() function copies size bytes of data specified by the source argument to an mbuf chain. The type argument specifies the method
used to perform a copy, and can be one of the following:
MB_MSYSTEM Use bcopy() function.
MB_MUSER Use copyin(9) function.
MB_MINLINE Use an ``inline'' loop which does not call any function.
MB_MZERO Do not copy any data, but just fill the destination with zero bytes.
MB_MCUSTOM Call function specified by the mbp->mb_copy field.
RETURN VALUES
All int functions except mb_fixhdr() return zero if successful and an error code otherwise.
Note: after failure of any function, an mbuf chain is left in the broken state, and only mb_done() function can safely be called to destroy
it.
EXAMPLES
struct mbchain *mbp;
struct mbuf *m;
mb_init(mbp);
mb_put_uint8(mbp, 33);
mb_put_uint16le(mbp, length);
m = m_copym(mbp->mb_top, 0, M_COPYALL, M_WAIT);
send(m);
mb_done(mbp);
SEE ALSO
mbuf(9), mdchain(9)
AUTHORS
This manual page was written by Boris Popov <bp@FreeBSD.org>.
BSD
February 20, 2001 BSD