Sponsored Content
Top Forums Shell Programming and Scripting Match files based on either of the two columns awk Post 302827203 by smitra on Friday 28th of June 2013 04:59:24 AM
Old 06-28-2013
Sorry Zaxxon,
I don't understand what you mean. My file one do not have a heading.
But fist col is ID and second col is count

Now I want to match this ID from either 1st or 2nd col of File 2

Then want to print the corresponding whole row of file 2 added with Col2 of first file.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk 3 files to one based on multiple columns

Hi all, I have three files, one is a navigation file, one is a depth file and one is a file containing the measured field of gravity. The formats of the files are; navigation file: 2006 320 17 39 0 0 *nav 21.31542 -157.887 2006 320 17 39 10 0 *nav 21.31542 -157.887 2006 320 17 39 20 0... (2 Replies)
Discussion started by: andrealphus
2 Replies

2. Shell Programming and Scripting

match columns using awk

Hi All, I need some help in writing a small script using Awk. My input file has following deatils A,B,C,D 8239359,8239359,8388125,8388125 8239359,8239359,8388125,8388125 7165981,7165981,8363138,8363138 8283830,8283830,8382987,8382987 8209964,8209964,8367098,8367098 ... (8 Replies)
Discussion started by: pistachio
8 Replies

3. Shell Programming and Scripting

match two key columns in two files and print output (awk)

I have two files... file1 and file2. Where columns 1 and 2 of file1 match columns 1 and 2 of file2 I want to create a new file that is all file1 + columns 3 and 4 of file2 :b: Many thanks if you know how to do this.... :b: file1 31-101 106 0 92 31-101 106 29 ... (2 Replies)
Discussion started by: pelhabuan
2 Replies

4. Shell Programming and Scripting

awk script to split file into multiple files based on many columns

So I have a space delimited file that I'd like to split into multiple files based on multiple column values. This is what my data looks like 1bc9A02 1 10 1000 FTDLNLVQALRQFLWSFRLPGEAQKIDRMMEAFAQRYCQCNNGVFQSTDTCYVLSFAIIMLNTSLHNPNVKDKPTVERFIAMNRGINDGGDLPEELLRNLYESIKNEPFKIPELEHHHHHH 1ku1A02 1 10... (9 Replies)
Discussion started by: viored
9 Replies

5. UNIX for Advanced & Expert Users

Match and print based on columns

HI, I have 2 different questions in this thread. Consider 2 files as input (input file have different line count ) File 1 1 1 625 56 1 12 657 34 1 9 25 45 1 2 20 54 67 3 25 35 27 4 45 73 36 5 125 56 45 File2 1 1 878 76 1 9 83 67 2 20 73 78 4 47 22 17 3 25 67 99 (4 Replies)
Discussion started by: rossi
4 Replies

6. Shell Programming and Scripting

New files based off match or no match

Trying to match $2 in original_targets with $2 of new_targets . If the two numbers match exactly then a match.txt file is outputted using the information in the new_targets in the beginning 4 fields $1, $2, $3, $4 and value of $4 in the original_targets . If there is "No Match" then a no... (2 Replies)
Discussion started by: cmccabe
2 Replies

7. Shell Programming and Scripting

awk to update file based on partial match in field1 and exact match in field2

I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output. $1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies

8. Shell Programming and Scripting

Comparing two columns in two files and printing a third based on a match

Hello all, First post here. I did not notice a previous post to help me down the right path. I am looking to compare a column in a CSV file against another file (which is not a column match one for one) but more or less when a match is made, I would like to append a third column that contains a... (17 Replies)
Discussion started by: dis0wned
17 Replies

9. Shell Programming and Scripting

awk to create subdirectory based on match between two files

In the below awk I am trying to mkdir based of an exact match between file2 line starting with R_2019.... and file1 line starting with R_2019. When a match is found there is a folder located at /home/cmccabe/run with the same name as the match where each $2 in file1 is a new subdirectory in that... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. UNIX for Beginners Questions & Answers

Data match 2 files based on first 2 columns matching only and join if match

Hi, i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file I have tried with join and awk and i keep getting blank outputs or same file is there an easier way than what i am... (4 Replies)
Discussion started by: axis88
4 Replies
overlay(3XCURSES)					  X/Open Curses Library Functions					 overlay(3XCURSES)

NAME
overlay, overwrite - copy overlapped windows SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int overlay(const WINDOW *srcwin, WINDOW *dstwin); int overwrite(const WINDOW *srcwin, WINDOW *dstwin); PARAMETERS
srcwin Is a pointer to the source window to be copied. dstwin Is a pointer to the destination window to be overlayed or overwritten. DESCRIPTION
The overwrite() and overlay() functions overlay srcwin on top of destwin. The srcwin and dstwin arguments do not have to be the same size; only text where the two windows overlap is copied. The overwrite() function copies characters as though a sequence of win_wch(3XCURSES) and wadd_wch(3XCURSES) were performed with the desti- nation window's attributes and background attributes cleared. The overlay() function does the same thing, except that, whenever a character to be copied is the background character of the source win- dow, overlay() does not copy the character but merely moves the destination cursor the width of the source background character. If any portion of the overlaying window border is not the first column of a multi-column character, then all the column positions will be replaced with the background character and rendition before the overlay is done. If the default background character is a multi-column character when this occurs, then these functions fail. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. EXAMPLES
Example 1: Implement a pop-up dialog The following example demonstrates the use of overwrite() to implement a pop-up dialog box. #include <curses.h> /* * Pop-up a window on top of curscr. If row and/or col * are -1 then that dimension will be centered within * curscr. Return 0 for success or -1 if malloc() failed. * Pass back the working window and the saved window for the * pop-up. The saved window should not be modified. */ int popup(work, save, nrows, ncols, row, col) WINDOW **work, **save; int nrows, ncols, row, col; { int mr, mc; getmaxyx(curscr, mr, mc); /* Windows are limited to the size of curscr. */ if (mr < nrows) nrows = mr; if (mc < ncols) ncols = mc; /* Center dimensions. */ if (row == -1) row = (mr-nrows)/2; if (col == -1) col = (mc-ncols)/2; /* The window must fit entirely in curscr. */ if (mr < row+nrows) row = 0; if (mc < col+ncols) col = 0; *work = newwin(nrows, ncols, row, col); if (*work == NULL) return (-1); if ((*save = dupwin(*work)) == NULL) { delwin(*work); return (-1); } overwrite(curscr, *save); return(0); } /* * Restore the region covered by a pop-up window. * Delete the working window and the saved window. * This function is the complement to popup(). Return * 0 for success or -1 for an error. */ int popdown(work, save) WINDOW *work, *save; { (void) wnoutrefresh(save); (void) delwin(save); (void) delwin(work); return(0); } /* * Compute the size of a dialog box that would fit around * the string. */ void dialsize(str, nrows, ncols) char *str; int *nrows, *ncols; { int rows, cols, col; for (rows = 1, cols = col = 0; *str != ''; ++str) { if (*str == ' ') { if (cols < col) cols = col; col = 0; ++rows; } else { ++col; } } if (cols < col) cols = col; *nrows = rows; *ncols = cols; } /* * Write a string into a dialog box. */ void dialfill(w, s) WINDOW *w; char *s; { int row; (void) wmove(w, 1, 1); for (row = 1; *s != ''; ++s) { (void) waddch(w, *((unsigned char*) s)); if (*s == ' ') wmove(w, ++row, 1); } box(w, 0, 0); } void dialog(str) char *str; { WINDOW *work, *save; int nrows, ncols, row, col; /* Figure out size of window. */ dialsize(str, &nrows, &ncols); /* Create a centered working window with extra */ /* room for a border. */ (void) popup(&work, &save, nrows+2, ncols+2, -1, -1); /* Write text into the working window. */ dialfill(work, str); /* Pause. Remember that wgetch() will do a wrefresh() */ /* for us. */ (void) wgetch(work); /* Restore curscr and free windows. */ (void) popdown(work, save); /* Redraw curscr to remove window from physical screen. */ (void) doupdate(); } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
copywin(3XCURSES), libcurses(3XCURSES), wadd_wch(3XCURSES), win_wch(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 overlay(3XCURSES)
All times are GMT -4. The time now is 05:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy