Sponsored Content
Top Forums Shell Programming and Scripting Comparing two files and printing 2nd column if match found Post 302470125 by gc_sw on Tuesday 9th of November 2010 08:45:40 AM
Old 11-09-2010
do you have solaris? if so; try:

Code:
nawk 'NR==FNR{a[$1,$2]=$3;next} a[$1,$2]{print $2}' file2 file1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

reading two files, comparing, printing when unmatched value is seen

Hello, I have two files: file1 1 2 3 4 5 file2 "a","b",,,,,"c","1",..... "s","d",,,,,"s","1",..... "a","c",,,,,"d","1",.... "f","v",,,,,,"f","2",..... etc I have to read "1" from file1 and grab all records in file2 (say column 6 in file2 is "1") until the column changes its value (... (6 Replies)
Discussion started by: i.scientist
6 Replies

2. Shell Programming and Scripting

printing words based on column match

pls help Input: file1 word1 text1 word2 text2 word3 text3 file2 word1 text11 word3 text13 can u pls help in getting the same output: file1 text1 text2 text3 (1 Reply)
Discussion started by: bha148
1 Replies

3. UNIX for Dummies Questions & Answers

Comparing the 2nd column in two different files and printing corresponding 9th columns in new file

Dear Gurus, I am very new to UNIX. I appreciate your help to manage my files. I have 16 files with equal number of columns in it. Each file has 9 columns separated by space. I need to compare the values in the second column of first file and obtain the corresponding value in the 9th column... (12 Replies)
Discussion started by: Unilearn
12 Replies

4. Shell Programming and Scripting

comparing column of two different files and print the column from in order of 2nd file

Hi friends, My file is like: Second file is : I need to print the rows present in file one, but in order present in second file....I used while read gh;do awk ' $1=="' $gh'" {print >> FILENAME"output"} ' cat listoffirstfile done < secondfile but the output I am... (14 Replies)
Discussion started by: CAch
14 Replies

5. UNIX for Dummies Questions & Answers

Comparing two text files by a column and printing values that do not match

I have two text files where the first three columns are exactly the same. I want to compare the fourth column of the text files and if the values are different, print that row into a new output file. How do I go about doing that? File 1: 100 rs3794811 0.01 0.3434 100 rs8066551 0.01... (8 Replies)
Discussion started by: evelibertine
8 Replies

6. Shell Programming and Scripting

Printing the line number of first column found

Hello, I have a question on how to find the line number of the first column that contains specific data. I know how to print all the line numbers of those columns, but haven't been able to figure out how to print only the first one that is found. For example, if my data has four columns: 115... (3 Replies)
Discussion started by: user553
3 Replies

7. UNIX for Dummies Questions & Answers

Comparing two test files and printing out the values that do not match

Hi, I have two text files with matching first columns. Some of the values in the second column do not match. I want to write a script to print out the rows (only the first column) where the values in the second column do not match. Example: Input 1 A 1 B 2 C 3 D 4 Input 2 A 2 B 2... (6 Replies)
Discussion started by: evelibertine
6 Replies

8. Shell Programming and Scripting

Comparing same column from two files, printing whole row with matching values

First I'd like to apologize if I opened a thread which is already open somewhere. I did a bit of searching but could quite find what I was looking for, so I will try to explaing what I need. I'm writing a script on our server, got to a point where I have two files with results. Example: File1... (6 Replies)
Discussion started by: mitabrev83
6 Replies

9. Shell Programming and Scripting

Comparing two one-line files and selecting what does not match

I have two files. One is consisting of one line, with data separated by spaces and each number appearing only once. The other is consisting of one column and multiple lines which can have some numbers appearing more than once. It looks something like this: file 1: 20 700 15 30 file2: 10... (10 Replies)
Discussion started by: maya3
10 Replies

10. 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
mencal(1)								 1								 mencal(1)

NAME
mencal - menstruation calendar SYNOPSIS
mencal [options] [file1 file2 ... -c CONF1 -c CONF2 ...] DESCRIPTION
Display options: -m, --monday draw monday as first weekday (sunday is default) -1 current month (default) -3 previous, current and next month -y [YYYY] all-year calendar (default YYYY is current year) -q, --quiet no top information will be printed -n, --nocolor noncolored output -i, --icolor COLOR intersection color (default red) available colors: red, green, blue, yellow, violet, cyan, shiny, bold mencal configuration: -c, --config s=[YYYY]MMDD,l=LL,d=DD,n=NAME,f=FILE,c=COLOR The second argument is a comma separated list of options. No spaces are allowed in this list. If no name is specified, 'Unknown' is used. Various -c options or filenames can be set. s,start=[YYYY]MMDD start day of period (default current day) l,length=LL length of period in days (default 28) d,duration=D duration of menstruation in days (default 4) n,name=NAME name of subject f,file=FILE filename to save configuration to (see section FILES) only menstruation related variables will be saved c,color=COLOR color used for menstruation days available colors: red, green, blue, yellow, violet, cyan, shiny, bold default color is red, with '-n' switch color settings are ignored Info options: -h, --help print help -V, --version print version information FILES
: $HOME/.mencalrc - the default configuration file that is automatically loaded AUTHOR
: (C) 2002 C. McCohy e-mail: <mccohy@kyberdigi.cz> Word-Wide-Web: http://www.kyberdigi.cz/projects/mencal/english This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page (but may be used by others). HISTORY
22 March 2002 - Originally written by Amaya Rodrigo <amaya@debian.org>. 24 Apr 2002 - New manpage contributed by Pablo S. Torralba <psanchez@skyrealms.org>. Amaya Rodrigo <amaya@debian.org> is now responsible for developing and maintaining this manual page. Comments and suggestions are greatly wellcome. mencal Menstruation calendar mencal(1)
All times are GMT -4. The time now is 08:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy