Sponsored Content
Top Forums Shell Programming and Scripting Comparing two columns in two files and printing a third based on a match Post 303023588 by dis0wned on Wednesday 19th of September 2018 01:32:35 PM
Old 09-19-2018
Please see below: I removed the dos carriage returns / line feeds and ran the command provided again.


Code:
TGY9 ~/testfiles/vlanint
$ tr -d '\015' <file2 >file22

TGY9 ~/testfiles/vlanint
$ awk 'FNR==NR{f2[$1]=$5;next} FNR==1{print $0, "VLAN Name";next} {print $0,($2 in f2)?f2[$2]:"NA"}' OFS=, file2 file1
Hostname,Port,Name,Status,Vlan,Duplex,Speed,Type,VLAN Name
onshintstat,Te1/1     ,     Trunk-to-    ,    connected    ,  trunk      ,      full ,           10G ,        10GBase-CU 3M,,NA
onshintstat,Te1/2     ,     Trunk-to-    ,    connected    ,  trunk      ,      full ,           10G ,        10GBase-CU 3M,,NA
onshintstat,Te1/3     ,     Trunk-to-   ,    connected    ,  trunk      ,      full ,           10G ,        10GBase-CU 3M,,NA
onshintstat,Te1/4     ,     Trunk-to-   ,    connected    ,  trunk      ,      full ,           10G ,        10GBase-CU 3M,,NA
onshintstat,Te1/5     ,     nexu  ,    connected    ,  572        ,      full ,           10G ,        10GBase-CU 3M,,NA
onshintstat,Te1/6     ,     nexu  ,    connected    ,  572        ,      full ,           10G ,        10GBase-CU 3M,,NA

Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, AND code segments.

Last edited by Don Cragun; 09-20-2018 at 04:47 PM.. Reason: Add CODE tags again.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing Columns and printing the difference from a particular file

Gurus, I have one file which is having multiple columns and also this file is not always contain the exact columns; sometimes it contains 5 columns or 12 columns. Now, I need to find the difference from that particular file. Here is the sample file: param1 | 10 | 20 | 30 | param2 | 10 |... (6 Replies)
Discussion started by: buzzusa
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. Shell Programming and Scripting

Comparing two files and printing 2nd column if match found

Hi guys, I'm rather new at using UNIX based systems, and when it comes to scripting etc I'm even newer. I have two files which i need to compare. file1: (some random ID's) 451245 451288 136588 784522 file2: (random ID's + e-mail assigned to ID) 123888 xc@xc.com 451245 ... (21 Replies)
Discussion started by: spirm8
21 Replies

4. 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

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. 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

7. Shell Programming and Scripting

Match files based on either of the two columns awk

Dear Shell experts, I have 2 files with structure: File 1: ID and count head test_GI_count1.txt 1000094 2 10039307 1 10039641 1 10047177 11 10047359 1 1008555 2 10120302 1 10120672 13 10121776 1 10121865 32 And 2nd file: head Protein_gi_GeneID_symbol.txt protein_gi GeneID... (11 Replies)
Discussion started by: smitra
11 Replies

8. Shell Programming and Scripting

Comparing Select Columns from two CSV files in UNIX and create a third file based on comparision

Hi , I want to compare first 3 columns of File A and File B and create a new file File C which will have all rows from File B and will include rows that are present in File A and not in File B based on First 3 column comparison. Thanks in advance for your help. File A A,B,C,45,46... (2 Replies)
Discussion started by: ady_koolz
2 Replies

9. Shell Programming and Scripting

awk pattern match not printing desired columns

Hi all, I'm trying to match the following two files with the code below: awk -F, 'NR==FNR {a=$0; next} ($12,$4) in a {print $12,$1,a}' OFS="," file4.csv file3.csv but the code does not print the entire row from file4 in addition to column 12 and 1 of file3. file4: o,c,q,co,ov,b... (1 Reply)
Discussion started by: bkane3
1 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
MXGE(4) 						   BSD Kernel Interfaces Manual 						   MXGE(4)

NAME
mxge -- Myricom Myri10GE 10 Gigabit Ethernet adapter driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device firmware device mxge Alternatively, to load the driver as a module at boot time, place the following lines in loader.conf(5): if_mxge_load="YES" mxge_ethp_z8e_load="YES" mxge_eth_z8e_load="YES" mxge_rss_ethp_z8e_load="YES" mxge_rss_eth_z8e_load="YES" DESCRIPTION
The mxge driver provides support for PCI Express 10 Gigabit Ethernet adapters based on the Myricom LANai Z8E chip. The driver supports Transmit/Receive checksum offload, Jumbo Frames, TCP segmentation offload (TSO) as well as Large Receive Offload (LRO). For further hardware information, see http://www.myri.com/. For questions related to hardware requirements, refer to the documentation supplied with your Myri10GE adapter. All hardware requirements listed apply to use with FreeBSD. Support for Jumbo Frames is provided via the interface MTU setting. Selecting an MTU larger than 1500 bytes with the ifconfig(8) utility configures the adapter to receive and transmit Jumbo Frames. The maximum MTU size for Jumbo Frames is 9000. For more information on configuring this device, see ifconfig(8). HARDWARE
The mxge driver supports 10 Gigabit Ethernet adapters based on the Myricom LANai Z8E chips: o Myricom 10GBase-CX4 (10G-PCIE-8A-C, 10G-PCIE-8AL-C) o Myricom 10GBase-R (10G-PCIE-8A-R, 10G-PCIE-8AL-R) o Myricom 10G XAUI over ribbon fiber (10G-PCIE-8A-Q, 10G-PCIE-8AL-Q) LOADER TUNABLES
Tunables can be set at the loader(8) prompt before booting the kernel or stored in loader.conf(5). hw.mxge.flow_control_enabled Whether or not hardware flow control is enabled on the adapter. The default value is 1. hw.mxge.intr_coal_delay This value delays the generation of all interrupts in units of 1 microsecond. The default value is 30. hw.mxge.skip_pio_read This value determines whether or not the driver may omit doing a PIO read in the interrupt handler which ensures that the interrupt line has been deasserted when using xPIC interrupts. A non-zero value may result in lower CPU overhead, however it may also result in spurious interrupts. The default value is 0. This tunable has no effect when the device is using MSI or MSI-X interrupts. hw.mxge.max_slices This value determines the maximum number of slices the driver will attempt to use. The default value is 1. A slice is comprised of a set of receive queues and an associated interrupt thread. When using multiple slices, the NIC hashes traffic to different slices based on the value of hw.mxge.rss_hashtype. Using multiple slices requires that your motherboard and Myri10GE NIC both be capable of MSI-X. Older Myri10GE NICs can be field upgraded to add MSI-X using the "10G NIC Tool Kit" for FreeBSD which is available from http://www.myri.com/scs/download-10g-tools.html. hw.mxge.rss_hashtype This value determines how incoming traffic is steered to different slices. This tunable is ignored when using just a single slice. The legal values for this tunable are: 1 Hash on the source and destination IPv4 addresses. 2 Hash on source and destination IPv4 addresses and if the packet is TCP, then also hash on the TCP source and destination ports. 4 Hash on the TCP or UDP source ports. This is the default value. DIAGNOSTICS
mxge%d: Unable to allocate bus resource: memory A fatal initialization error has occurred. mxge%d: Unable to allocate bus resource: interrupt A fatal initialization error has occurred. mxge%d: Could not find firmware image %s The appropriate firmware kld module was not installed. This is a non-fatal initialization error, but will result in running in a reduced performance mode. SUPPORT
For general information and support, go to the Myricom support website at: http://www.myri.com/scs/. If an issue is identified with the released source code on the supported kernel with a supported adapter, email the specific information related to the issue to <help@myri.com>. SEE ALSO
altq(4), arp(4), netintro(4), ng_ether(4), ifconfig(8) HISTORY
The mxge device driver first appeared in FreeBSD 6.3. AUTHORS
The mxge driver was written by Andrew Gallatin <gallatin@FreeBSD.org>. BSD
February 13, 2008 BSD
All times are GMT -4. The time now is 05:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy